UNPKG

878 kBJavaScriptView Raw
1/*!
2 * Swagger Parser v6.0.5 (January 25th 2019)
3 *
4 * https://apidevtools.org/swagger-parser/
5 *
6 * @author James Messinger (https://jamesmessinger.com)
7 * @license MIT
8 */
9(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.SwaggerParser = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
10"use strict";
11
12var validateSchema = require("./validators/schema"),
13 validateSpec = require("./validators/spec"),
14 normalizeArgs = require("json-schema-ref-parser/lib/normalize-args"),
15 util = require("./util"),
16 Options = require("./options"),
17 maybe = require("call-me-maybe"),
18 ono = require("ono"),
19 $RefParser = require("json-schema-ref-parser"),
20 dereference = require("json-schema-ref-parser/lib/dereference");
21
22module.exports = SwaggerParser;
23
24/**
25 * This class parses a Swagger 2.0 or 3.0 API, resolves its JSON references and their resolved values,
26 * and provides methods for traversing, dereferencing, and validating the API.
27 *
28 * @constructor
29 * @extends $RefParser
30 */
31function SwaggerParser () {
32 $RefParser.apply(this, arguments);
33}
34
35util.inherits(SwaggerParser, $RefParser);
36SwaggerParser.YAML = $RefParser.YAML;
37SwaggerParser.parse = $RefParser.parse;
38SwaggerParser.resolve = $RefParser.resolve;
39SwaggerParser.bundle = $RefParser.bundle;
40SwaggerParser.dereference = $RefParser.dereference;
41
42/**
43 * Alias {@link $RefParser#schema} as {@link SwaggerParser#api}
44 */
45Object.defineProperty(SwaggerParser.prototype, "api", {
46 configurable: true,
47 enumerable: true,
48 get: function () {
49 return this.schema;
50 }
51});
52
53/**
54 * Parses the given Swagger API.
55 * This method does not resolve any JSON references.
56 * It just reads a single file in JSON or YAML format, and parse it as a JavaScript object.
57 *
58 * @param {string} [path] - The file path or URL of the JSON schema
59 * @param {object} [api] - The Swagger API object. This object will be used instead of reading from `path`.
60 * @param {ParserOptions} [options] - Options that determine how the API is parsed
61 * @param {function} [callback] - An error-first callback. The second parameter is the parsed API object.
62 * @returns {Promise} - The returned promise resolves with the parsed API object.
63 */
64SwaggerParser.prototype.parse = function (path, api, options, callback) {
65 var args = normalizeArgs(arguments);
66 args.options = new Options(args.options);
67
68 return $RefParser.prototype.parse.call(this, args.path, args.schema, args.options)
69 .then(function (schema) {
70 if (schema.swagger) {
71 // Verify that the parsed object is a Swagger API
72 if (schema.swagger === undefined || schema.info === undefined || schema.paths === undefined) {
73 throw ono.syntax("%s is not a valid Swagger API definition", args.path || args.schema);
74 }
75 else if (typeof schema.swagger === "number") {
76 // This is a very common mistake, so give a helpful error message
77 throw ono.syntax('Swagger version number must be a string (e.g. "2.0") not a number.');
78 }
79 else if (typeof schema.info.version === "number") {
80 // This is a very common mistake, so give a helpful error message
81 throw ono.syntax('API version number must be a string (e.g. "1.0.0") not a number.');
82 }
83 else if (schema.swagger !== "2.0") {
84 throw ono.syntax("Unrecognized Swagger version: %d. Expected 2.0", schema.swagger);
85 }
86 }
87 else {
88 var supportedVersions = ["3.0.0", "3.0.1", "3.0.2"];
89
90 // Verify that the parsed object is a Openapi API
91 if (schema.openapi === undefined || schema.info === undefined || schema.paths === undefined) {
92 throw ono.syntax("%s is not a valid Openapi API definition", args.path || args.schema);
93 }
94 else if (typeof schema.openapi === "number") {
95 // This is a very common mistake, so give a helpful error message
96 throw ono.syntax('Openapi version number must be a string (e.g. "3.0.0") not a number.');
97 }
98 else if (typeof schema.info.version === "number") {
99 // This is a very common mistake, so give a helpful error message
100 throw ono.syntax('API version number must be a string (e.g. "1.0.0") not a number.');
101 }
102 else if (supportedVersions.indexOf(schema.openapi) === -1) {
103 throw ono.syntax(
104 "Unsupported OpenAPI version: %d. Swagger Parser only supports versions %s",
105 schema.openapi, supportedVersions.join(", "));
106 }
107 }
108
109 // Looks good!
110 return maybe(args.callback, Promise.resolve(schema));
111 })
112 .catch(function (err) {
113 return maybe(args.callback, Promise.reject(err));
114 });
115};
116
117/**
118 * Parses, dereferences, and validates the given Swagger API.
119 * Depending on the options, validation can include JSON Schema validation and/or Swagger Spec validation.
120 *
121 * @param {string} [path] - The file path or URL of the JSON schema
122 * @param {object} [api] - The Swagger API object. This object will be used instead of reading from `path`.
123 * @param {ParserOptions} [options] - Options that determine how the API is parsed, dereferenced, and validated
124 * @param {function} [callback] - An error-first callback. The second parameter is the parsed API object.
125 * @returns {Promise} - The returned promise resolves with the parsed API object.
126 */
127SwaggerParser.validate = function (path, api, options, callback) {
128 var Class = this; // eslint-disable-line consistent-this
129 var instance = new Class();
130 return instance.validate.apply(instance, arguments);
131};
132
133/**
134 * Parses, dereferences, and validates the given Swagger API.
135 * Depending on the options, validation can include JSON Schema validation and/or Swagger Spec validation.
136 *
137 * @param {string} [path] - The file path or URL of the JSON schema
138 * @param {object} [api] - The Swagger API object. This object will be used instead of reading from `path`.
139 * @param {ParserOptions} [options] - Options that determine how the API is parsed, dereferenced, and validated
140 * @param {function} [callback] - An error-first callback. The second parameter is the parsed API object.
141 * @returns {Promise} - The returned promise resolves with the parsed API object.
142 */
143SwaggerParser.prototype.validate = function (path, api, options, callback) {
144 var me = this;
145 var args = normalizeArgs(arguments);
146 args.options = new Options(args.options);
147
148 // ZSchema doesn't support circular objects, so don't dereference circular $refs yet
149 // (see https://github.com/zaggino/z-schema/issues/137)
150 var circular$RefOption = args.options.dereference.circular;
151 args.options.validate.schema && (args.options.dereference.circular = "ignore");
152
153 return this.dereference(args.path, args.schema, args.options)
154 .then(function () {
155 // Restore the original options, now that we're done dereferencing
156 args.options.dereference.circular = circular$RefOption;
157
158 if (args.options.validate.schema) {
159 // Validate the API against the Swagger schema
160 // NOTE: This is safe to do, because we haven't dereferenced circular $refs yet
161 validateSchema(me.api);
162
163 if (me.$refs.circular) {
164 if (circular$RefOption === true) {
165 // The API has circular references,
166 // so we need to do a second-pass to fully-dereference it
167 dereference(me, args.options);
168 }
169 else if (circular$RefOption === false) {
170 // The API has circular references, and they're not allowed, so throw an error
171 throw ono.reference("The API contains circular references");
172 }
173 }
174 }
175
176 if (args.options.validate.spec) {
177 // Validate the API against the Swagger spec
178 validateSpec(me.api);
179 }
180
181 return maybe(args.callback, Promise.resolve(me.schema));
182 })
183 .catch(function (err) {
184 return maybe(args.callback, Promise.reject(err));
185 });
186};
187
188/**
189 * The Swagger object
190 * https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object
191 *
192 * @typedef {{swagger: string, info: {}, paths: {}}} SwaggerObject
193 */
194
195},{"./options":2,"./util":3,"./validators/schema":4,"./validators/spec":5,"call-me-maybe":11,"json-schema-ref-parser":103,"json-schema-ref-parser/lib/dereference":102,"json-schema-ref-parser/lib/normalize-args":104,"ono":122}],2:[function(require,module,exports){
196"use strict";
197
198var $RefParserOptions = require("json-schema-ref-parser/lib/options"),
199 schemaValidator = require("./validators/schema"),
200 specValidator = require("./validators/spec"),
201 util = require("util");
202
203module.exports = ParserOptions;
204
205/**
206 * Options that determine how Swagger APIs are parsed, resolved, dereferenced, and validated.
207 *
208 * @param {object|ParserOptions} [options] - Overridden options
209 * @constructor
210 * @extends $RefParserOptions
211 */
212function ParserOptions (options) {
213 $RefParserOptions.call(this, ParserOptions.defaults);
214 $RefParserOptions.apply(this, arguments);
215}
216
217ParserOptions.defaults = {
218 /**
219 * Determines how the API definition will be validated.
220 *
221 * You can add additional validators of your own, replace an existing one with
222 * your own implemenation, or disable any validator by setting it to false.
223 */
224 validate: {
225 schema: schemaValidator,
226 spec: specValidator,
227 },
228};
229
230util.inherits(ParserOptions, $RefParserOptions);
231
232},{"./validators/schema":4,"./validators/spec":5,"json-schema-ref-parser/lib/options":105,"util":152}],3:[function(require,module,exports){
233"use strict";
234
235var util = require("util");
236
237exports.format = util.format;
238exports.inherits = util.inherits;
239
240/**
241 * Regular Expression that matches Swagger path params.
242 */
243exports.swaggerParamRegExp = /\{([^/}]+)}/g;
244
245},{"util":152}],4:[function(require,module,exports){
246"use strict";
247
248var util = require("../util"),
249 ono = require("ono"),
250 ZSchema = require("z-schema");
251
252module.exports = validateSchema;
253
254initializeZSchema();
255
256/**
257 * Validates the given Swagger API against the Swagger 2.0 or 3.0 schema.
258 *
259 * @param {SwaggerObject} api
260 */
261function validateSchema (api) {
262 // Choose the appropriate schema (Swagger or OpenAPI)
263 var schema = api.swagger
264 ? require("swagger-schema-official/schema.json")
265 : require("openapi-schema-validation/schema/openapi-3.0.json");
266
267 var isValid = ZSchema.validate(api, schema);
268
269 if (!isValid) {
270 var err = ZSchema.getLastError();
271 var message = "Swagger schema validation failed. \n" + formatZSchemaError(err.details);
272 throw ono.syntax(err, { details: err.details }, message);
273 }
274}
275
276/**
277 * Performs one-time initialization logic to prepare for Swagger Schema validation.
278 */
279function initializeZSchema () {
280 ZSchema = new ZSchema({
281 breakOnFirstError: true,
282 noExtraKeywords: true,
283 ignoreUnknownFormats: false,
284 reportPathAsArray: true
285 });
286}
287
288/**
289 * Z-Schema validation errors are a nested tree structure.
290 * This function crawls that tree and builds an error message string.
291 *
292 * @param {object[]} errors - The Z-Schema error details
293 * @param {string} [indent] - The whitespace used to indent the error message
294 * @returns {string}
295 */
296function formatZSchemaError (errors, indent) {
297 indent = indent || " ";
298 var message = "";
299 errors.forEach(function (error, index) {
300 message += util.format("%s%s at #/%s\n", indent, error.message, error.path.join("/"));
301 if (error.inner) {
302 message += formatZSchemaError(error.inner, indent + " ");
303 }
304 });
305 return message;
306}
307
308},{"../util":3,"ono":122,"openapi-schema-validation/schema/openapi-3.0.json":123,"swagger-schema-official/schema.json":145,"z-schema":241}],5:[function(require,module,exports){
309"use strict";
310
311var util = require("../util"),
312 ono = require("ono"),
313 swaggerMethods = require("swagger-methods"),
314 primitiveTypes = ["array", "boolean", "integer", "number", "string"],
315 schemaTypes = ["array", "boolean", "integer", "number", "string", "object", "null", undefined];
316
317module.exports = validateSpec;
318
319/**
320 * Validates parts of the Swagger 2.0 spec that aren't covered by the Swagger 2.0 JSON Schema.
321 *
322 * @param {SwaggerObject} api
323 */
324function validateSpec (api) {
325 if (api.openapi) {
326 // We don't (yet) support validating against the OpenAPI spec
327 return;
328 }
329
330 var paths = Object.keys(api.paths || {});
331 var operationIds = [];
332 paths.forEach(function (pathName) {
333 var path = api.paths[pathName];
334 var pathId = "/paths" + pathName;
335
336 if (path && pathName.indexOf("/") === 0) {
337 validatePath(api, path, pathId, operationIds);
338 }
339 });
340 var definitions = Object.keys(api.definitions || {});
341 definitions.forEach(function (definitionName) {
342 var definition = api.definitions[definitionName];
343 var definitionId = "/definitions/" + definitionName;
344 validateRequiredPropertiesExist(definition, definitionId);
345 });
346}
347
348/**
349 * Validates the given path.
350 *
351 * @param {SwaggerObject} api - The entire Swagger API object
352 * @param {object} path - A Path object, from the Swagger API
353 * @param {string} pathId - A value that uniquely identifies the path
354 * @param {string} operationIds - An array of collected operationIds found in other paths
355 */
356function validatePath (api, path, pathId, operationIds) {
357 swaggerMethods.forEach(function (operationName) {
358 var operation = path[operationName];
359 var operationId = pathId + "/" + operationName;
360
361 if (operation) {
362 var declaredOperationId = operation.operationId;
363 if (declaredOperationId) {
364 if (operationIds.indexOf(declaredOperationId) === -1) {
365 operationIds.push(declaredOperationId);
366 }
367 else {
368 throw ono.syntax("Validation failed. Duplicate operation id '%s'", declaredOperationId);
369 }
370 }
371 validateParameters(api, path, pathId, operation, operationId);
372
373 var responses = Object.keys(operation.responses || {});
374 responses.forEach(function (responseName) {
375 var response = operation.responses[responseName];
376 var responseId = operationId + "/responses/" + responseName;
377 validateResponse(responseName, (response || {}), responseId);
378 });
379 }
380 });
381}
382
383/**
384 * Validates the parameters for the given operation.
385 *
386 * @param {SwaggerObject} api - The entire Swagger API object
387 * @param {object} path - A Path object, from the Swagger API
388 * @param {string} pathId - A value that uniquely identifies the path
389 * @param {object} operation - An Operation object, from the Swagger API
390 * @param {string} operationId - A value that uniquely identifies the operation
391 */
392function validateParameters (api, path, pathId, operation, operationId) {
393 var pathParams = path.parameters || [];
394 var operationParams = operation.parameters || [];
395
396 // Check for duplicate path parameters
397 try {
398 checkForDuplicates(pathParams);
399 }
400 catch (e) {
401 throw ono.syntax(e, "Validation failed. %s has duplicate parameters", pathId);
402 }
403
404 // Check for duplicate operation parameters
405 try {
406 checkForDuplicates(operationParams);
407 }
408 catch (e) {
409 throw ono.syntax(e, "Validation failed. %s has duplicate parameters", operationId);
410 }
411
412 // Combine the path and operation parameters,
413 // with the operation params taking precedence over the path params
414 var params = pathParams.reduce(function (combinedParams, value) {
415 var duplicate = combinedParams.some(function (param) {
416 return param.in === value.in && param.name === value.name;
417 });
418 if (!duplicate) {
419 combinedParams.push(value);
420 }
421 return combinedParams;
422 }, operationParams.slice());
423
424 validateBodyParameters(params, operationId);
425 validatePathParameters(params, pathId, operationId);
426 validateParameterTypes(params, api, operation, operationId);
427}
428
429/**
430 * Validates body and formData parameters for the given operation.
431 *
432 * @param {object[]} params - An array of Parameter objects
433 * @param {string} operationId - A value that uniquely identifies the operation
434 */
435function validateBodyParameters (params, operationId) {
436 var bodyParams = params.filter(function (param) { return param.in === "body"; });
437 var formParams = params.filter(function (param) { return param.in === "formData"; });
438
439 // There can only be one "body" parameter
440 if (bodyParams.length > 1) {
441 throw ono.syntax(
442 "Validation failed. %s has %d body parameters. Only one is allowed.",
443 operationId, bodyParams.length
444 );
445 }
446 else if (bodyParams.length > 0 && formParams.length > 0) {
447 // "body" params and "formData" params are mutually exclusive
448 throw ono.syntax(
449 "Validation failed. %s has body parameters and formData parameters. Only one or the other is allowed.",
450 operationId
451 );
452 }
453}
454
455/**
456 * Validates path parameters for the given path.
457 *
458 * @param {object[]} params - An array of Parameter objects
459 * @param {string} pathId - A value that uniquely identifies the path
460 * @param {string} operationId - A value that uniquely identifies the operation
461 */
462function validatePathParameters (params, pathId, operationId) {
463 // Find all {placeholders} in the path string
464 var placeholders = pathId.match(util.swaggerParamRegExp) || [];
465
466 // Check for duplicates
467 for (var i = 0; i < placeholders.length; i++) {
468 for (var j = i + 1; j < placeholders.length; j++) {
469 if (placeholders[i] === placeholders[j]) {
470 throw ono.syntax(
471 "Validation failed. %s has multiple path placeholders named %s", operationId, placeholders[i]);
472 }
473 }
474 }
475
476 params
477 .filter(function (param) { return param.in === "path"; })
478 .forEach(function (param) {
479 if (param.required !== true) {
480 throw ono.syntax(
481 'Validation failed. Path parameters cannot be optional. Set required=true for the "%s" parameter at %s',
482 param.name,
483 operationId
484 );
485 }
486 var match = placeholders.indexOf("{" + param.name + "}");
487 if (match === -1) {
488 throw ono.syntax(
489 'Validation failed. %s has a path parameter named "%s", ' +
490 "but there is no corresponding {%s} in the path string",
491 operationId,
492 param.name,
493 param.name
494 );
495 }
496 placeholders.splice(match, 1);
497 });
498
499 if (placeholders.length > 0) {
500 throw ono.syntax("Validation failed. %s is missing path parameter(s) for %s", operationId, placeholders);
501 }
502}
503
504/**
505 * Validates data types of parameters for the given operation.
506 *
507 * @param {object[]} params - An array of Parameter objects
508 * @param {object} api - The entire Swagger API object
509 * @param {object} operation - An Operation object, from the Swagger API
510 * @param {string} operationId - A value that uniquely identifies the operation
511 */
512function validateParameterTypes (params, api, operation, operationId) {
513 params.forEach(function (param) {
514 var parameterId = operationId + "/parameters/" + param.name;
515 var schema, validTypes;
516
517 switch (param.in) {
518 case "body":
519 schema = param.schema;
520 validTypes = schemaTypes;
521 break;
522 case "formData":
523 schema = param;
524 validTypes = primitiveTypes.concat("file");
525 break;
526 default:
527 schema = param;
528 validTypes = primitiveTypes;
529 }
530
531 validateSchema(schema, parameterId, validTypes);
532 validateRequiredPropertiesExist(schema, parameterId);
533
534 if (schema.type === "file") {
535 // "file" params must consume at least one of these MIME types
536 var formData = /multipart\/(.*\+)?form-data/;
537 var urlEncoded = /application\/(.*\+)?x-www-form-urlencoded/;
538
539 var consumes = operation.consumes || api.consumes || [];
540
541 var hasValidMimeType = consumes.some(function (consume) {
542 return formData.test(consume) || urlEncoded.test(consume);
543 });
544
545 if (!hasValidMimeType) {
546 throw ono.syntax(
547 "Validation failed. %s has a file parameter, so it must consume multipart/form-data " +
548 "or application/x-www-form-urlencoded",
549 operationId
550 );
551 }
552 }
553 });
554}
555
556/**
557 * Checks the given parameter list for duplicates, and throws an error if found.
558 *
559 * @param {object[]} params - An array of Parameter objects
560 */
561function checkForDuplicates (params) {
562 for (var i = 0; i < params.length - 1; i++) {
563 var outer = params[i];
564 for (var j = i + 1; j < params.length; j++) {
565 var inner = params[j];
566 if (outer.name === inner.name && outer.in === inner.in) {
567 throw ono.syntax('Validation failed. Found multiple %s parameters named "%s"', outer.in, outer.name);
568 }
569 }
570 }
571}
572
573/**
574 * Validates the given response object.
575 *
576 * @param {string} code - The HTTP response code (or "default")
577 * @param {object} response - A Response object, from the Swagger API
578 * @param {string} responseId - A value that uniquely identifies the response
579 */
580function validateResponse (code, response, responseId) {
581 if (code !== "default" && (code < 100 || code > 599)) {
582 throw ono.syntax("Validation failed. %s has an invalid response code (%s)", responseId, code);
583 }
584
585 var headers = Object.keys(response.headers || {});
586 headers.forEach(function (headerName) {
587 var header = response.headers[headerName];
588 var headerId = responseId + "/headers/" + headerName;
589 validateSchema(header, headerId, primitiveTypes);
590 });
591
592 if (response.schema) {
593 var validTypes = schemaTypes.concat("file");
594 if (validTypes.indexOf(response.schema.type) === -1) {
595 throw ono.syntax(
596 "Validation failed. %s has an invalid response schema type (%s)", responseId, response.schema.type);
597 }
598 else {
599 validateSchema(response.schema, responseId + "/schema", validTypes);
600 }
601 }
602}
603
604/**
605 * Validates the given Swagger schema object.
606 *
607 * @param {object} schema - A Schema object, from the Swagger API
608 * @param {string} schemaId - A value that uniquely identifies the schema object
609 * @param {string[]} validTypes - An array of the allowed schema types
610 */
611function validateSchema (schema, schemaId, validTypes) {
612 if (validTypes.indexOf(schema.type) === -1) {
613 throw ono.syntax(
614 "Validation failed. %s has an invalid type (%s)", schemaId, schema.type);
615 }
616
617 if (schema.type === "array" && !schema.items) {
618 throw ono.syntax('Validation failed. %s is an array, so it must include an "items" schema', schemaId);
619 }
620}
621
622/**
623 * Validates that the declared properties of the given Swagger schema object actually exist.
624 *
625 * @param {object} schema - A Schema object, from the Swagger API
626 * @param {string} schemaId - A value that uniquely identifies the schema object
627 */
628function validateRequiredPropertiesExist (schema, schemaId) {
629 /**
630 * Recursively collects all properties of the schema and its ancestors. They are added to the props object.
631 */
632 function collectProperties (schemaObj, props) {
633 if (schemaObj.properties) {
634 for (var property in schemaObj.properties) {
635 if (schemaObj.properties.hasOwnProperty(property)) {
636 props[property] = schemaObj.properties[property];
637 }
638 }
639 }
640 if (schemaObj.allOf) {
641 schemaObj.allOf.forEach(function (parent) {
642 collectProperties(parent, props);
643 });
644 }
645 }
646
647 if (schema.required && Array.isArray(schema.required)) {
648 var props = {};
649 collectProperties(schema, props);
650 schema.required.forEach(function (requiredProperty) {
651 if (!props[requiredProperty]) {
652 throw ono.syntax("Validation failed. Property '%s' listed as required but does not exist in '%s'",
653 requiredProperty, schemaId);
654 }
655 });
656 }
657}
658
659},{"../util":3,"ono":122,"swagger-methods":144}],6:[function(require,module,exports){
660'use strict'
661
662exports.byteLength = byteLength
663exports.toByteArray = toByteArray
664exports.fromByteArray = fromByteArray
665
666var lookup = []
667var revLookup = []
668var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
669
670var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
671for (var i = 0, len = code.length; i < len; ++i) {
672 lookup[i] = code[i]
673 revLookup[code.charCodeAt(i)] = i
674}
675
676// Support decoding URL-safe base64 strings, as Node.js does.
677// See: https://en.wikipedia.org/wiki/Base64#URL_applications
678revLookup['-'.charCodeAt(0)] = 62
679revLookup['_'.charCodeAt(0)] = 63
680
681function getLens (b64) {
682 var len = b64.length
683
684 if (len % 4 > 0) {
685 throw new Error('Invalid string. Length must be a multiple of 4')
686 }
687
688 // Trim off extra bytes after placeholder bytes are found
689 // See: https://github.com/beatgammit/base64-js/issues/42
690 var validLen = b64.indexOf('=')
691 if (validLen === -1) validLen = len
692
693 var placeHoldersLen = validLen === len
694 ? 0
695 : 4 - (validLen % 4)
696
697 return [validLen, placeHoldersLen]
698}
699
700// base64 is 4/3 + up to two characters of the original data
701function byteLength (b64) {
702 var lens = getLens(b64)
703 var validLen = lens[0]
704 var placeHoldersLen = lens[1]
705 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
706}
707
708function _byteLength (b64, validLen, placeHoldersLen) {
709 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
710}
711
712function toByteArray (b64) {
713 var tmp
714 var lens = getLens(b64)
715 var validLen = lens[0]
716 var placeHoldersLen = lens[1]
717
718 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
719
720 var curByte = 0
721
722 // if there are placeholders, only get up to the last complete 4 chars
723 var len = placeHoldersLen > 0
724 ? validLen - 4
725 : validLen
726
727 for (var i = 0; i < len; i += 4) {
728 tmp =
729 (revLookup[b64.charCodeAt(i)] << 18) |
730 (revLookup[b64.charCodeAt(i + 1)] << 12) |
731 (revLookup[b64.charCodeAt(i + 2)] << 6) |
732 revLookup[b64.charCodeAt(i + 3)]
733 arr[curByte++] = (tmp >> 16) & 0xFF
734 arr[curByte++] = (tmp >> 8) & 0xFF
735 arr[curByte++] = tmp & 0xFF
736 }
737
738 if (placeHoldersLen === 2) {
739 tmp =
740 (revLookup[b64.charCodeAt(i)] << 2) |
741 (revLookup[b64.charCodeAt(i + 1)] >> 4)
742 arr[curByte++] = tmp & 0xFF
743 }
744
745 if (placeHoldersLen === 1) {
746 tmp =
747 (revLookup[b64.charCodeAt(i)] << 10) |
748 (revLookup[b64.charCodeAt(i + 1)] << 4) |
749 (revLookup[b64.charCodeAt(i + 2)] >> 2)
750 arr[curByte++] = (tmp >> 8) & 0xFF
751 arr[curByte++] = tmp & 0xFF
752 }
753
754 return arr
755}
756
757function tripletToBase64 (num) {
758 return lookup[num >> 18 & 0x3F] +
759 lookup[num >> 12 & 0x3F] +
760 lookup[num >> 6 & 0x3F] +
761 lookup[num & 0x3F]
762}
763
764function encodeChunk (uint8, start, end) {
765 var tmp
766 var output = []
767 for (var i = start; i < end; i += 3) {
768 tmp =
769 ((uint8[i] << 16) & 0xFF0000) +
770 ((uint8[i + 1] << 8) & 0xFF00) +
771 (uint8[i + 2] & 0xFF)
772 output.push(tripletToBase64(tmp))
773 }
774 return output.join('')
775}
776
777function fromByteArray (uint8) {
778 var tmp
779 var len = uint8.length
780 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
781 var parts = []
782 var maxChunkLength = 16383 // must be multiple of 3
783
784 // go through the array every three bytes, we'll deal with trailing stuff later
785 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
786 parts.push(encodeChunk(
787 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
788 ))
789 }
790
791 // pad the end with zeros, but make sure to not forget the extra bytes
792 if (extraBytes === 1) {
793 tmp = uint8[len - 1]
794 parts.push(
795 lookup[tmp >> 2] +
796 lookup[(tmp << 4) & 0x3F] +
797 '=='
798 )
799 } else if (extraBytes === 2) {
800 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
801 parts.push(
802 lookup[tmp >> 10] +
803 lookup[(tmp >> 4) & 0x3F] +
804 lookup[(tmp << 2) & 0x3F] +
805 '='
806 )
807 }
808
809 return parts.join('')
810}
811
812},{}],7:[function(require,module,exports){
813
814},{}],8:[function(require,module,exports){
815(function (global){
816/*! https://mths.be/punycode v1.4.1 by @mathias */
817;(function(root) {
818
819 /** Detect free variables */
820 var freeExports = typeof exports == 'object' && exports &&
821 !exports.nodeType && exports;
822 var freeModule = typeof module == 'object' && module &&
823 !module.nodeType && module;
824 var freeGlobal = typeof global == 'object' && global;
825 if (
826 freeGlobal.global === freeGlobal ||
827 freeGlobal.window === freeGlobal ||
828 freeGlobal.self === freeGlobal
829 ) {
830 root = freeGlobal;
831 }
832
833 /**
834 * The `punycode` object.
835 * @name punycode
836 * @type Object
837 */
838 var punycode,
839
840 /** Highest positive signed 32-bit float value */
841 maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
842
843 /** Bootstring parameters */
844 base = 36,
845 tMin = 1,
846 tMax = 26,
847 skew = 38,
848 damp = 700,
849 initialBias = 72,
850 initialN = 128, // 0x80
851 delimiter = '-', // '\x2D'
852
853 /** Regular expressions */
854 regexPunycode = /^xn--/,
855 regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
856 regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
857
858 /** Error messages */
859 errors = {
860 'overflow': 'Overflow: input needs wider integers to process',
861 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
862 'invalid-input': 'Invalid input'
863 },
864
865 /** Convenience shortcuts */
866 baseMinusTMin = base - tMin,
867 floor = Math.floor,
868 stringFromCharCode = String.fromCharCode,
869
870 /** Temporary variable */
871 key;
872
873 /*--------------------------------------------------------------------------*/
874
875 /**
876 * A generic error utility function.
877 * @private
878 * @param {String} type The error type.
879 * @returns {Error} Throws a `RangeError` with the applicable error message.
880 */
881 function error(type) {
882 throw new RangeError(errors[type]);
883 }
884
885 /**
886 * A generic `Array#map` utility function.
887 * @private
888 * @param {Array} array The array to iterate over.
889 * @param {Function} callback The function that gets called for every array
890 * item.
891 * @returns {Array} A new array of values returned by the callback function.
892 */
893 function map(array, fn) {
894 var length = array.length;
895 var result = [];
896 while (length--) {
897 result[length] = fn(array[length]);
898 }
899 return result;
900 }
901
902 /**
903 * A simple `Array#map`-like wrapper to work with domain name strings or email
904 * addresses.
905 * @private
906 * @param {String} domain The domain name or email address.
907 * @param {Function} callback The function that gets called for every
908 * character.
909 * @returns {Array} A new string of characters returned by the callback
910 * function.
911 */
912 function mapDomain(string, fn) {
913 var parts = string.split('@');
914 var result = '';
915 if (parts.length > 1) {
916 // In email addresses, only the domain name should be punycoded. Leave
917 // the local part (i.e. everything up to `@`) intact.
918 result = parts[0] + '@';
919 string = parts[1];
920 }
921 // Avoid `split(regex)` for IE8 compatibility. See #17.
922 string = string.replace(regexSeparators, '\x2E');
923 var labels = string.split('.');
924 var encoded = map(labels, fn).join('.');
925 return result + encoded;
926 }
927
928 /**
929 * Creates an array containing the numeric code points of each Unicode
930 * character in the string. While JavaScript uses UCS-2 internally,
931 * this function will convert a pair of surrogate halves (each of which
932 * UCS-2 exposes as separate characters) into a single code point,
933 * matching UTF-16.
934 * @see `punycode.ucs2.encode`
935 * @see <https://mathiasbynens.be/notes/javascript-encoding>
936 * @memberOf punycode.ucs2
937 * @name decode
938 * @param {String} string The Unicode input string (UCS-2).
939 * @returns {Array} The new array of code points.
940 */
941 function ucs2decode(string) {
942 var output = [],
943 counter = 0,
944 length = string.length,
945 value,
946 extra;
947 while (counter < length) {
948 value = string.charCodeAt(counter++);
949 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
950 // high surrogate, and there is a next character
951 extra = string.charCodeAt(counter++);
952 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
953 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
954 } else {
955 // unmatched surrogate; only append this code unit, in case the next
956 // code unit is the high surrogate of a surrogate pair
957 output.push(value);
958 counter--;
959 }
960 } else {
961 output.push(value);
962 }
963 }
964 return output;
965 }
966
967 /**
968 * Creates a string based on an array of numeric code points.
969 * @see `punycode.ucs2.decode`
970 * @memberOf punycode.ucs2
971 * @name encode
972 * @param {Array} codePoints The array of numeric code points.
973 * @returns {String} The new Unicode string (UCS-2).
974 */
975 function ucs2encode(array) {
976 return map(array, function(value) {
977 var output = '';
978 if (value > 0xFFFF) {
979 value -= 0x10000;
980 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
981 value = 0xDC00 | value & 0x3FF;
982 }
983 output += stringFromCharCode(value);
984 return output;
985 }).join('');
986 }
987
988 /**
989 * Converts a basic code point into a digit/integer.
990 * @see `digitToBasic()`
991 * @private
992 * @param {Number} codePoint The basic numeric code point value.
993 * @returns {Number} The numeric value of a basic code point (for use in
994 * representing integers) in the range `0` to `base - 1`, or `base` if
995 * the code point does not represent a value.
996 */
997 function basicToDigit(codePoint) {
998 if (codePoint - 48 < 10) {
999 return codePoint - 22;
1000 }
1001 if (codePoint - 65 < 26) {
1002 return codePoint - 65;
1003 }
1004 if (codePoint - 97 < 26) {
1005 return codePoint - 97;
1006 }
1007 return base;
1008 }
1009
1010 /**
1011 * Converts a digit/integer into a basic code point.
1012 * @see `basicToDigit()`
1013 * @private
1014 * @param {Number} digit The numeric value of a basic code point.
1015 * @returns {Number} The basic code point whose value (when used for
1016 * representing integers) is `digit`, which needs to be in the range
1017 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
1018 * used; else, the lowercase form is used. The behavior is undefined
1019 * if `flag` is non-zero and `digit` has no uppercase form.
1020 */
1021 function digitToBasic(digit, flag) {
1022 // 0..25 map to ASCII a..z or A..Z
1023 // 26..35 map to ASCII 0..9
1024 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
1025 }
1026
1027 /**
1028 * Bias adaptation function as per section 3.4 of RFC 3492.
1029 * https://tools.ietf.org/html/rfc3492#section-3.4
1030 * @private
1031 */
1032 function adapt(delta, numPoints, firstTime) {
1033 var k = 0;
1034 delta = firstTime ? floor(delta / damp) : delta >> 1;
1035 delta += floor(delta / numPoints);
1036 for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
1037 delta = floor(delta / baseMinusTMin);
1038 }
1039 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
1040 }
1041
1042 /**
1043 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
1044 * symbols.
1045 * @memberOf punycode
1046 * @param {String} input The Punycode string of ASCII-only symbols.
1047 * @returns {String} The resulting string of Unicode symbols.
1048 */
1049 function decode(input) {
1050 // Don't use UCS-2
1051 var output = [],
1052 inputLength = input.length,
1053 out,
1054 i = 0,
1055 n = initialN,
1056 bias = initialBias,
1057 basic,
1058 j,
1059 index,
1060 oldi,
1061 w,
1062 k,
1063 digit,
1064 t,
1065 /** Cached calculation results */
1066 baseMinusT;
1067
1068 // Handle the basic code points: let `basic` be the number of input code
1069 // points before the last delimiter, or `0` if there is none, then copy
1070 // the first basic code points to the output.
1071
1072 basic = input.lastIndexOf(delimiter);
1073 if (basic < 0) {
1074 basic = 0;
1075 }
1076
1077 for (j = 0; j < basic; ++j) {
1078 // if it's not a basic code point
1079 if (input.charCodeAt(j) >= 0x80) {
1080 error('not-basic');
1081 }
1082 output.push(input.charCodeAt(j));
1083 }
1084
1085 // Main decoding loop: start just after the last delimiter if any basic code
1086 // points were copied; start at the beginning otherwise.
1087
1088 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
1089
1090 // `index` is the index of the next character to be consumed.
1091 // Decode a generalized variable-length integer into `delta`,
1092 // which gets added to `i`. The overflow checking is easier
1093 // if we increase `i` as we go, then subtract off its starting
1094 // value at the end to obtain `delta`.
1095 for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
1096
1097 if (index >= inputLength) {
1098 error('invalid-input');
1099 }
1100
1101 digit = basicToDigit(input.charCodeAt(index++));
1102
1103 if (digit >= base || digit > floor((maxInt - i) / w)) {
1104 error('overflow');
1105 }
1106
1107 i += digit * w;
1108 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
1109
1110 if (digit < t) {
1111 break;
1112 }
1113
1114 baseMinusT = base - t;
1115 if (w > floor(maxInt / baseMinusT)) {
1116 error('overflow');
1117 }
1118
1119 w *= baseMinusT;
1120
1121 }
1122
1123 out = output.length + 1;
1124 bias = adapt(i - oldi, out, oldi == 0);
1125
1126 // `i` was supposed to wrap around from `out` to `0`,
1127 // incrementing `n` each time, so we'll fix that now:
1128 if (floor(i / out) > maxInt - n) {
1129 error('overflow');
1130 }
1131
1132 n += floor(i / out);
1133 i %= out;
1134
1135 // Insert `n` at position `i` of the output
1136 output.splice(i++, 0, n);
1137
1138 }
1139
1140 return ucs2encode(output);
1141 }
1142
1143 /**
1144 * Converts a string of Unicode symbols (e.g. a domain name label) to a
1145 * Punycode string of ASCII-only symbols.
1146 * @memberOf punycode
1147 * @param {String} input The string of Unicode symbols.
1148 * @returns {String} The resulting Punycode string of ASCII-only symbols.
1149 */
1150 function encode(input) {
1151 var n,
1152 delta,
1153 handledCPCount,
1154 basicLength,
1155 bias,
1156 j,
1157 m,
1158 q,
1159 k,
1160 t,
1161 currentValue,
1162 output = [],
1163 /** `inputLength` will hold the number of code points in `input`. */
1164 inputLength,
1165 /** Cached calculation results */
1166 handledCPCountPlusOne,
1167 baseMinusT,
1168 qMinusT;
1169
1170 // Convert the input in UCS-2 to Unicode
1171 input = ucs2decode(input);
1172
1173 // Cache the length
1174 inputLength = input.length;
1175
1176 // Initialize the state
1177 n = initialN;
1178 delta = 0;
1179 bias = initialBias;
1180
1181 // Handle the basic code points
1182 for (j = 0; j < inputLength; ++j) {
1183 currentValue = input[j];
1184 if (currentValue < 0x80) {
1185 output.push(stringFromCharCode(currentValue));
1186 }
1187 }
1188
1189 handledCPCount = basicLength = output.length;
1190
1191 // `handledCPCount` is the number of code points that have been handled;
1192 // `basicLength` is the number of basic code points.
1193
1194 // Finish the basic string - if it is not empty - with a delimiter
1195 if (basicLength) {
1196 output.push(delimiter);
1197 }
1198
1199 // Main encoding loop:
1200 while (handledCPCount < inputLength) {
1201
1202 // All non-basic code points < n have been handled already. Find the next
1203 // larger one:
1204 for (m = maxInt, j = 0; j < inputLength; ++j) {
1205 currentValue = input[j];
1206 if (currentValue >= n && currentValue < m) {
1207 m = currentValue;
1208 }
1209 }
1210
1211 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
1212 // but guard against overflow
1213 handledCPCountPlusOne = handledCPCount + 1;
1214 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
1215 error('overflow');
1216 }
1217
1218 delta += (m - n) * handledCPCountPlusOne;
1219 n = m;
1220
1221 for (j = 0; j < inputLength; ++j) {
1222 currentValue = input[j];
1223
1224 if (currentValue < n && ++delta > maxInt) {
1225 error('overflow');
1226 }
1227
1228 if (currentValue == n) {
1229 // Represent delta as a generalized variable-length integer
1230 for (q = delta, k = base; /* no condition */; k += base) {
1231 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
1232 if (q < t) {
1233 break;
1234 }
1235 qMinusT = q - t;
1236 baseMinusT = base - t;
1237 output.push(
1238 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
1239 );
1240 q = floor(qMinusT / baseMinusT);
1241 }
1242
1243 output.push(stringFromCharCode(digitToBasic(q, 0)));
1244 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
1245 delta = 0;
1246 ++handledCPCount;
1247 }
1248 }
1249
1250 ++delta;
1251 ++n;
1252
1253 }
1254 return output.join('');
1255 }
1256
1257 /**
1258 * Converts a Punycode string representing a domain name or an email address
1259 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
1260 * it doesn't matter if you call it on a string that has already been
1261 * converted to Unicode.
1262 * @memberOf punycode
1263 * @param {String} input The Punycoded domain name or email address to
1264 * convert to Unicode.
1265 * @returns {String} The Unicode representation of the given Punycode
1266 * string.
1267 */
1268 function toUnicode(input) {
1269 return mapDomain(input, function(string) {
1270 return regexPunycode.test(string)
1271 ? decode(string.slice(4).toLowerCase())
1272 : string;
1273 });
1274 }
1275
1276 /**
1277 * Converts a Unicode string representing a domain name or an email address to
1278 * Punycode. Only the non-ASCII parts of the domain name will be converted,
1279 * i.e. it doesn't matter if you call it with a domain that's already in
1280 * ASCII.
1281 * @memberOf punycode
1282 * @param {String} input The domain name or email address to convert, as a
1283 * Unicode string.
1284 * @returns {String} The Punycode representation of the given domain name or
1285 * email address.
1286 */
1287 function toASCII(input) {
1288 return mapDomain(input, function(string) {
1289 return regexNonASCII.test(string)
1290 ? 'xn--' + encode(string)
1291 : string;
1292 });
1293 }
1294
1295 /*--------------------------------------------------------------------------*/
1296
1297 /** Define the public API */
1298 punycode = {
1299 /**
1300 * A string representing the current Punycode.js version number.
1301 * @memberOf punycode
1302 * @type String
1303 */
1304 'version': '1.4.1',
1305 /**
1306 * An object of methods to convert from JavaScript's internal character
1307 * representation (UCS-2) to Unicode code points, and back.
1308 * @see <https://mathiasbynens.be/notes/javascript-encoding>
1309 * @memberOf punycode
1310 * @type Object
1311 */
1312 'ucs2': {
1313 'decode': ucs2decode,
1314 'encode': ucs2encode
1315 },
1316 'decode': decode,
1317 'encode': encode,
1318 'toASCII': toASCII,
1319 'toUnicode': toUnicode
1320 };
1321
1322 /** Expose `punycode` */
1323 // Some AMD build optimizers, like r.js, check for specific condition patterns
1324 // like the following:
1325 if (
1326 typeof define == 'function' &&
1327 typeof define.amd == 'object' &&
1328 define.amd
1329 ) {
1330 define('punycode', function() {
1331 return punycode;
1332 });
1333 } else if (freeExports && freeModule) {
1334 if (module.exports == freeExports) {
1335 // in Node.js, io.js, or RingoJS v0.8.0+
1336 freeModule.exports = punycode;
1337 } else {
1338 // in Narwhal or RingoJS v0.7.0-
1339 for (key in punycode) {
1340 punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
1341 }
1342 }
1343 } else {
1344 // in Rhino or a web browser
1345 root.punycode = punycode;
1346 }
1347
1348}(this));
1349
1350}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1351
1352},{}],9:[function(require,module,exports){
1353/*!
1354 * The buffer module from node.js, for the browser.
1355 *
1356 * @author Feross Aboukhadijeh <https://feross.org>
1357 * @license MIT
1358 */
1359/* eslint-disable no-proto */
1360
1361'use strict'
1362
1363var base64 = require('base64-js')
1364var ieee754 = require('ieee754')
1365
1366exports.Buffer = Buffer
1367exports.SlowBuffer = SlowBuffer
1368exports.INSPECT_MAX_BYTES = 50
1369
1370var K_MAX_LENGTH = 0x7fffffff
1371exports.kMaxLength = K_MAX_LENGTH
1372
1373/**
1374 * If `Buffer.TYPED_ARRAY_SUPPORT`:
1375 * === true Use Uint8Array implementation (fastest)
1376 * === false Print warning and recommend using `buffer` v4.x which has an Object
1377 * implementation (most compatible, even IE6)
1378 *
1379 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
1380 * Opera 11.6+, iOS 4.2+.
1381 *
1382 * We report that the browser does not support typed arrays if the are not subclassable
1383 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
1384 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
1385 * for __proto__ and has a buggy typed array implementation.
1386 */
1387Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
1388
1389if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
1390 typeof console.error === 'function') {
1391 console.error(
1392 'This browser lacks typed array (Uint8Array) support which is required by ' +
1393 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
1394 )
1395}
1396
1397function typedArraySupport () {
1398 // Can typed array instances can be augmented?
1399 try {
1400 var arr = new Uint8Array(1)
1401 arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
1402 return arr.foo() === 42
1403 } catch (e) {
1404 return false
1405 }
1406}
1407
1408Object.defineProperty(Buffer.prototype, 'parent', {
1409 enumerable: true,
1410 get: function () {
1411 if (!Buffer.isBuffer(this)) return undefined
1412 return this.buffer
1413 }
1414})
1415
1416Object.defineProperty(Buffer.prototype, 'offset', {
1417 enumerable: true,
1418 get: function () {
1419 if (!Buffer.isBuffer(this)) return undefined
1420 return this.byteOffset
1421 }
1422})
1423
1424function createBuffer (length) {
1425 if (length > K_MAX_LENGTH) {
1426 throw new RangeError('The value "' + length + '" is invalid for option "size"')
1427 }
1428 // Return an augmented `Uint8Array` instance
1429 var buf = new Uint8Array(length)
1430 buf.__proto__ = Buffer.prototype
1431 return buf
1432}
1433
1434/**
1435 * The Buffer constructor returns instances of `Uint8Array` that have their
1436 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
1437 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
1438 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
1439 * returns a single octet.
1440 *
1441 * The `Uint8Array` prototype remains unmodified.
1442 */
1443
1444function Buffer (arg, encodingOrOffset, length) {
1445 // Common case.
1446 if (typeof arg === 'number') {
1447 if (typeof encodingOrOffset === 'string') {
1448 throw new TypeError(
1449 'The "string" argument must be of type string. Received type number'
1450 )
1451 }
1452 return allocUnsafe(arg)
1453 }
1454 return from(arg, encodingOrOffset, length)
1455}
1456
1457// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
1458if (typeof Symbol !== 'undefined' && Symbol.species != null &&
1459 Buffer[Symbol.species] === Buffer) {
1460 Object.defineProperty(Buffer, Symbol.species, {
1461 value: null,
1462 configurable: true,
1463 enumerable: false,
1464 writable: false
1465 })
1466}
1467
1468Buffer.poolSize = 8192 // not used by this implementation
1469
1470function from (value, encodingOrOffset, length) {
1471 if (typeof value === 'string') {
1472 return fromString(value, encodingOrOffset)
1473 }
1474
1475 if (ArrayBuffer.isView(value)) {
1476 return fromArrayLike(value)
1477 }
1478
1479 if (value == null) {
1480 throw TypeError(
1481 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
1482 'or Array-like Object. Received type ' + (typeof value)
1483 )
1484 }
1485
1486 if (isInstance(value, ArrayBuffer) ||
1487 (value && isInstance(value.buffer, ArrayBuffer))) {
1488 return fromArrayBuffer(value, encodingOrOffset, length)
1489 }
1490
1491 if (typeof value === 'number') {
1492 throw new TypeError(
1493 'The "value" argument must not be of type number. Received type number'
1494 )
1495 }
1496
1497 var valueOf = value.valueOf && value.valueOf()
1498 if (valueOf != null && valueOf !== value) {
1499 return Buffer.from(valueOf, encodingOrOffset, length)
1500 }
1501
1502 var b = fromObject(value)
1503 if (b) return b
1504
1505 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
1506 typeof value[Symbol.toPrimitive] === 'function') {
1507 return Buffer.from(
1508 value[Symbol.toPrimitive]('string'), encodingOrOffset, length
1509 )
1510 }
1511
1512 throw new TypeError(
1513 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
1514 'or Array-like Object. Received type ' + (typeof value)
1515 )
1516}
1517
1518/**
1519 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
1520 * if value is a number.
1521 * Buffer.from(str[, encoding])
1522 * Buffer.from(array)
1523 * Buffer.from(buffer)
1524 * Buffer.from(arrayBuffer[, byteOffset[, length]])
1525 **/
1526Buffer.from = function (value, encodingOrOffset, length) {
1527 return from(value, encodingOrOffset, length)
1528}
1529
1530// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
1531// https://github.com/feross/buffer/pull/148
1532Buffer.prototype.__proto__ = Uint8Array.prototype
1533Buffer.__proto__ = Uint8Array
1534
1535function assertSize (size) {
1536 if (typeof size !== 'number') {
1537 throw new TypeError('"size" argument must be of type number')
1538 } else if (size < 0) {
1539 throw new RangeError('The value "' + size + '" is invalid for option "size"')
1540 }
1541}
1542
1543function alloc (size, fill, encoding) {
1544 assertSize(size)
1545 if (size <= 0) {
1546 return createBuffer(size)
1547 }
1548 if (fill !== undefined) {
1549 // Only pay attention to encoding if it's a string. This
1550 // prevents accidentally sending in a number that would
1551 // be interpretted as a start offset.
1552 return typeof encoding === 'string'
1553 ? createBuffer(size).fill(fill, encoding)
1554 : createBuffer(size).fill(fill)
1555 }
1556 return createBuffer(size)
1557}
1558
1559/**
1560 * Creates a new filled Buffer instance.
1561 * alloc(size[, fill[, encoding]])
1562 **/
1563Buffer.alloc = function (size, fill, encoding) {
1564 return alloc(size, fill, encoding)
1565}
1566
1567function allocUnsafe (size) {
1568 assertSize(size)
1569 return createBuffer(size < 0 ? 0 : checked(size) | 0)
1570}
1571
1572/**
1573 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
1574 * */
1575Buffer.allocUnsafe = function (size) {
1576 return allocUnsafe(size)
1577}
1578/**
1579 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
1580 */
1581Buffer.allocUnsafeSlow = function (size) {
1582 return allocUnsafe(size)
1583}
1584
1585function fromString (string, encoding) {
1586 if (typeof encoding !== 'string' || encoding === '') {
1587 encoding = 'utf8'
1588 }
1589
1590 if (!Buffer.isEncoding(encoding)) {
1591 throw new TypeError('Unknown encoding: ' + encoding)
1592 }
1593
1594 var length = byteLength(string, encoding) | 0
1595 var buf = createBuffer(length)
1596
1597 var actual = buf.write(string, encoding)
1598
1599 if (actual !== length) {
1600 // Writing a hex string, for example, that contains invalid characters will
1601 // cause everything after the first invalid character to be ignored. (e.g.
1602 // 'abxxcd' will be treated as 'ab')
1603 buf = buf.slice(0, actual)
1604 }
1605
1606 return buf
1607}
1608
1609function fromArrayLike (array) {
1610 var length = array.length < 0 ? 0 : checked(array.length) | 0
1611 var buf = createBuffer(length)
1612 for (var i = 0; i < length; i += 1) {
1613 buf[i] = array[i] & 255
1614 }
1615 return buf
1616}
1617
1618function fromArrayBuffer (array, byteOffset, length) {
1619 if (byteOffset < 0 || array.byteLength < byteOffset) {
1620 throw new RangeError('"offset" is outside of buffer bounds')
1621 }
1622
1623 if (array.byteLength < byteOffset + (length || 0)) {
1624 throw new RangeError('"length" is outside of buffer bounds')
1625 }
1626
1627 var buf
1628 if (byteOffset === undefined && length === undefined) {
1629 buf = new Uint8Array(array)
1630 } else if (length === undefined) {
1631 buf = new Uint8Array(array, byteOffset)
1632 } else {
1633 buf = new Uint8Array(array, byteOffset, length)
1634 }
1635
1636 // Return an augmented `Uint8Array` instance
1637 buf.__proto__ = Buffer.prototype
1638 return buf
1639}
1640
1641function fromObject (obj) {
1642 if (Buffer.isBuffer(obj)) {
1643 var len = checked(obj.length) | 0
1644 var buf = createBuffer(len)
1645
1646 if (buf.length === 0) {
1647 return buf
1648 }
1649
1650 obj.copy(buf, 0, 0, len)
1651 return buf
1652 }
1653
1654 if (obj.length !== undefined) {
1655 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
1656 return createBuffer(0)
1657 }
1658 return fromArrayLike(obj)
1659 }
1660
1661 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
1662 return fromArrayLike(obj.data)
1663 }
1664}
1665
1666function checked (length) {
1667 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
1668 // length is NaN (which is otherwise coerced to zero.)
1669 if (length >= K_MAX_LENGTH) {
1670 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
1671 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
1672 }
1673 return length | 0
1674}
1675
1676function SlowBuffer (length) {
1677 if (+length != length) { // eslint-disable-line eqeqeq
1678 length = 0
1679 }
1680 return Buffer.alloc(+length)
1681}
1682
1683Buffer.isBuffer = function isBuffer (b) {
1684 return b != null && b._isBuffer === true &&
1685 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
1686}
1687
1688Buffer.compare = function compare (a, b) {
1689 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
1690 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
1691 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
1692 throw new TypeError(
1693 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
1694 )
1695 }
1696
1697 if (a === b) return 0
1698
1699 var x = a.length
1700 var y = b.length
1701
1702 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
1703 if (a[i] !== b[i]) {
1704 x = a[i]
1705 y = b[i]
1706 break
1707 }
1708 }
1709
1710 if (x < y) return -1
1711 if (y < x) return 1
1712 return 0
1713}
1714
1715Buffer.isEncoding = function isEncoding (encoding) {
1716 switch (String(encoding).toLowerCase()) {
1717 case 'hex':
1718 case 'utf8':
1719 case 'utf-8':
1720 case 'ascii':
1721 case 'latin1':
1722 case 'binary':
1723 case 'base64':
1724 case 'ucs2':
1725 case 'ucs-2':
1726 case 'utf16le':
1727 case 'utf-16le':
1728 return true
1729 default:
1730 return false
1731 }
1732}
1733
1734Buffer.concat = function concat (list, length) {
1735 if (!Array.isArray(list)) {
1736 throw new TypeError('"list" argument must be an Array of Buffers')
1737 }
1738
1739 if (list.length === 0) {
1740 return Buffer.alloc(0)
1741 }
1742
1743 var i
1744 if (length === undefined) {
1745 length = 0
1746 for (i = 0; i < list.length; ++i) {
1747 length += list[i].length
1748 }
1749 }
1750
1751 var buffer = Buffer.allocUnsafe(length)
1752 var pos = 0
1753 for (i = 0; i < list.length; ++i) {
1754 var buf = list[i]
1755 if (isInstance(buf, Uint8Array)) {
1756 buf = Buffer.from(buf)
1757 }
1758 if (!Buffer.isBuffer(buf)) {
1759 throw new TypeError('"list" argument must be an Array of Buffers')
1760 }
1761 buf.copy(buffer, pos)
1762 pos += buf.length
1763 }
1764 return buffer
1765}
1766
1767function byteLength (string, encoding) {
1768 if (Buffer.isBuffer(string)) {
1769 return string.length
1770 }
1771 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
1772 return string.byteLength
1773 }
1774 if (typeof string !== 'string') {
1775 throw new TypeError(
1776 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
1777 'Received type ' + typeof string
1778 )
1779 }
1780
1781 var len = string.length
1782 var mustMatch = (arguments.length > 2 && arguments[2] === true)
1783 if (!mustMatch && len === 0) return 0
1784
1785 // Use a for loop to avoid recursion
1786 var loweredCase = false
1787 for (;;) {
1788 switch (encoding) {
1789 case 'ascii':
1790 case 'latin1':
1791 case 'binary':
1792 return len
1793 case 'utf8':
1794 case 'utf-8':
1795 return utf8ToBytes(string).length
1796 case 'ucs2':
1797 case 'ucs-2':
1798 case 'utf16le':
1799 case 'utf-16le':
1800 return len * 2
1801 case 'hex':
1802 return len >>> 1
1803 case 'base64':
1804 return base64ToBytes(string).length
1805 default:
1806 if (loweredCase) {
1807 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
1808 }
1809 encoding = ('' + encoding).toLowerCase()
1810 loweredCase = true
1811 }
1812 }
1813}
1814Buffer.byteLength = byteLength
1815
1816function slowToString (encoding, start, end) {
1817 var loweredCase = false
1818
1819 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1820 // property of a typed array.
1821
1822 // This behaves neither like String nor Uint8Array in that we set start/end
1823 // to their upper/lower bounds if the value passed is out of range.
1824 // undefined is handled specially as per ECMA-262 6th Edition,
1825 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1826 if (start === undefined || start < 0) {
1827 start = 0
1828 }
1829 // Return early if start > this.length. Done here to prevent potential uint32
1830 // coercion fail below.
1831 if (start > this.length) {
1832 return ''
1833 }
1834
1835 if (end === undefined || end > this.length) {
1836 end = this.length
1837 }
1838
1839 if (end <= 0) {
1840 return ''
1841 }
1842
1843 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
1844 end >>>= 0
1845 start >>>= 0
1846
1847 if (end <= start) {
1848 return ''
1849 }
1850
1851 if (!encoding) encoding = 'utf8'
1852
1853 while (true) {
1854 switch (encoding) {
1855 case 'hex':
1856 return hexSlice(this, start, end)
1857
1858 case 'utf8':
1859 case 'utf-8':
1860 return utf8Slice(this, start, end)
1861
1862 case 'ascii':
1863 return asciiSlice(this, start, end)
1864
1865 case 'latin1':
1866 case 'binary':
1867 return latin1Slice(this, start, end)
1868
1869 case 'base64':
1870 return base64Slice(this, start, end)
1871
1872 case 'ucs2':
1873 case 'ucs-2':
1874 case 'utf16le':
1875 case 'utf-16le':
1876 return utf16leSlice(this, start, end)
1877
1878 default:
1879 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1880 encoding = (encoding + '').toLowerCase()
1881 loweredCase = true
1882 }
1883 }
1884}
1885
1886// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
1887// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
1888// reliably in a browserify context because there could be multiple different
1889// copies of the 'buffer' package in use. This method works even for Buffer
1890// instances that were created from another copy of the `buffer` package.
1891// See: https://github.com/feross/buffer/issues/154
1892Buffer.prototype._isBuffer = true
1893
1894function swap (b, n, m) {
1895 var i = b[n]
1896 b[n] = b[m]
1897 b[m] = i
1898}
1899
1900Buffer.prototype.swap16 = function swap16 () {
1901 var len = this.length
1902 if (len % 2 !== 0) {
1903 throw new RangeError('Buffer size must be a multiple of 16-bits')
1904 }
1905 for (var i = 0; i < len; i += 2) {
1906 swap(this, i, i + 1)
1907 }
1908 return this
1909}
1910
1911Buffer.prototype.swap32 = function swap32 () {
1912 var len = this.length
1913 if (len % 4 !== 0) {
1914 throw new RangeError('Buffer size must be a multiple of 32-bits')
1915 }
1916 for (var i = 0; i < len; i += 4) {
1917 swap(this, i, i + 3)
1918 swap(this, i + 1, i + 2)
1919 }
1920 return this
1921}
1922
1923Buffer.prototype.swap64 = function swap64 () {
1924 var len = this.length
1925 if (len % 8 !== 0) {
1926 throw new RangeError('Buffer size must be a multiple of 64-bits')
1927 }
1928 for (var i = 0; i < len; i += 8) {
1929 swap(this, i, i + 7)
1930 swap(this, i + 1, i + 6)
1931 swap(this, i + 2, i + 5)
1932 swap(this, i + 3, i + 4)
1933 }
1934 return this
1935}
1936
1937Buffer.prototype.toString = function toString () {
1938 var length = this.length
1939 if (length === 0) return ''
1940 if (arguments.length === 0) return utf8Slice(this, 0, length)
1941 return slowToString.apply(this, arguments)
1942}
1943
1944Buffer.prototype.toLocaleString = Buffer.prototype.toString
1945
1946Buffer.prototype.equals = function equals (b) {
1947 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1948 if (this === b) return true
1949 return Buffer.compare(this, b) === 0
1950}
1951
1952Buffer.prototype.inspect = function inspect () {
1953 var str = ''
1954 var max = exports.INSPECT_MAX_BYTES
1955 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
1956 if (this.length > max) str += ' ... '
1957 return '<Buffer ' + str + '>'
1958}
1959
1960Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1961 if (isInstance(target, Uint8Array)) {
1962 target = Buffer.from(target, target.offset, target.byteLength)
1963 }
1964 if (!Buffer.isBuffer(target)) {
1965 throw new TypeError(
1966 'The "target" argument must be one of type Buffer or Uint8Array. ' +
1967 'Received type ' + (typeof target)
1968 )
1969 }
1970
1971 if (start === undefined) {
1972 start = 0
1973 }
1974 if (end === undefined) {
1975 end = target ? target.length : 0
1976 }
1977 if (thisStart === undefined) {
1978 thisStart = 0
1979 }
1980 if (thisEnd === undefined) {
1981 thisEnd = this.length
1982 }
1983
1984 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1985 throw new RangeError('out of range index')
1986 }
1987
1988 if (thisStart >= thisEnd && start >= end) {
1989 return 0
1990 }
1991 if (thisStart >= thisEnd) {
1992 return -1
1993 }
1994 if (start >= end) {
1995 return 1
1996 }
1997
1998 start >>>= 0
1999 end >>>= 0
2000 thisStart >>>= 0
2001 thisEnd >>>= 0
2002
2003 if (this === target) return 0
2004
2005 var x = thisEnd - thisStart
2006 var y = end - start
2007 var len = Math.min(x, y)
2008
2009 var thisCopy = this.slice(thisStart, thisEnd)
2010 var targetCopy = target.slice(start, end)
2011
2012 for (var i = 0; i < len; ++i) {
2013 if (thisCopy[i] !== targetCopy[i]) {
2014 x = thisCopy[i]
2015 y = targetCopy[i]
2016 break
2017 }
2018 }
2019
2020 if (x < y) return -1
2021 if (y < x) return 1
2022 return 0
2023}
2024
2025// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
2026// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
2027//
2028// Arguments:
2029// - buffer - a Buffer to search
2030// - val - a string, Buffer, or number
2031// - byteOffset - an index into `buffer`; will be clamped to an int32
2032// - encoding - an optional encoding, relevant is val is a string
2033// - dir - true for indexOf, false for lastIndexOf
2034function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
2035 // Empty buffer means no match
2036 if (buffer.length === 0) return -1
2037
2038 // Normalize byteOffset
2039 if (typeof byteOffset === 'string') {
2040 encoding = byteOffset
2041 byteOffset = 0
2042 } else if (byteOffset > 0x7fffffff) {
2043 byteOffset = 0x7fffffff
2044 } else if (byteOffset < -0x80000000) {
2045 byteOffset = -0x80000000
2046 }
2047 byteOffset = +byteOffset // Coerce to Number.
2048 if (numberIsNaN(byteOffset)) {
2049 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
2050 byteOffset = dir ? 0 : (buffer.length - 1)
2051 }
2052
2053 // Normalize byteOffset: negative offsets start from the end of the buffer
2054 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
2055 if (byteOffset >= buffer.length) {
2056 if (dir) return -1
2057 else byteOffset = buffer.length - 1
2058 } else if (byteOffset < 0) {
2059 if (dir) byteOffset = 0
2060 else return -1
2061 }
2062
2063 // Normalize val
2064 if (typeof val === 'string') {
2065 val = Buffer.from(val, encoding)
2066 }
2067
2068 // Finally, search either indexOf (if dir is true) or lastIndexOf
2069 if (Buffer.isBuffer(val)) {
2070 // Special case: looking for empty string/buffer always fails
2071 if (val.length === 0) {
2072 return -1
2073 }
2074 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
2075 } else if (typeof val === 'number') {
2076 val = val & 0xFF // Search for a byte value [0-255]
2077 if (typeof Uint8Array.prototype.indexOf === 'function') {
2078 if (dir) {
2079 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
2080 } else {
2081 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
2082 }
2083 }
2084 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
2085 }
2086
2087 throw new TypeError('val must be string, number or Buffer')
2088}
2089
2090function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
2091 var indexSize = 1
2092 var arrLength = arr.length
2093 var valLength = val.length
2094
2095 if (encoding !== undefined) {
2096 encoding = String(encoding).toLowerCase()
2097 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
2098 encoding === 'utf16le' || encoding === 'utf-16le') {
2099 if (arr.length < 2 || val.length < 2) {
2100 return -1
2101 }
2102 indexSize = 2
2103 arrLength /= 2
2104 valLength /= 2
2105 byteOffset /= 2
2106 }
2107 }
2108
2109 function read (buf, i) {
2110 if (indexSize === 1) {
2111 return buf[i]
2112 } else {
2113 return buf.readUInt16BE(i * indexSize)
2114 }
2115 }
2116
2117 var i
2118 if (dir) {
2119 var foundIndex = -1
2120 for (i = byteOffset; i < arrLength; i++) {
2121 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
2122 if (foundIndex === -1) foundIndex = i
2123 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
2124 } else {
2125 if (foundIndex !== -1) i -= i - foundIndex
2126 foundIndex = -1
2127 }
2128 }
2129 } else {
2130 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
2131 for (i = byteOffset; i >= 0; i--) {
2132 var found = true
2133 for (var j = 0; j < valLength; j++) {
2134 if (read(arr, i + j) !== read(val, j)) {
2135 found = false
2136 break
2137 }
2138 }
2139 if (found) return i
2140 }
2141 }
2142
2143 return -1
2144}
2145
2146Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
2147 return this.indexOf(val, byteOffset, encoding) !== -1
2148}
2149
2150Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
2151 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
2152}
2153
2154Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
2155 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
2156}
2157
2158function hexWrite (buf, string, offset, length) {
2159 offset = Number(offset) || 0
2160 var remaining = buf.length - offset
2161 if (!length) {
2162 length = remaining
2163 } else {
2164 length = Number(length)
2165 if (length > remaining) {
2166 length = remaining
2167 }
2168 }
2169
2170 var strLen = string.length
2171
2172 if (length > strLen / 2) {
2173 length = strLen / 2
2174 }
2175 for (var i = 0; i < length; ++i) {
2176 var parsed = parseInt(string.substr(i * 2, 2), 16)
2177 if (numberIsNaN(parsed)) return i
2178 buf[offset + i] = parsed
2179 }
2180 return i
2181}
2182
2183function utf8Write (buf, string, offset, length) {
2184 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
2185}
2186
2187function asciiWrite (buf, string, offset, length) {
2188 return blitBuffer(asciiToBytes(string), buf, offset, length)
2189}
2190
2191function latin1Write (buf, string, offset, length) {
2192 return asciiWrite(buf, string, offset, length)
2193}
2194
2195function base64Write (buf, string, offset, length) {
2196 return blitBuffer(base64ToBytes(string), buf, offset, length)
2197}
2198
2199function ucs2Write (buf, string, offset, length) {
2200 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
2201}
2202
2203Buffer.prototype.write = function write (string, offset, length, encoding) {
2204 // Buffer#write(string)
2205 if (offset === undefined) {
2206 encoding = 'utf8'
2207 length = this.length
2208 offset = 0
2209 // Buffer#write(string, encoding)
2210 } else if (length === undefined && typeof offset === 'string') {
2211 encoding = offset
2212 length = this.length
2213 offset = 0
2214 // Buffer#write(string, offset[, length][, encoding])
2215 } else if (isFinite(offset)) {
2216 offset = offset >>> 0
2217 if (isFinite(length)) {
2218 length = length >>> 0
2219 if (encoding === undefined) encoding = 'utf8'
2220 } else {
2221 encoding = length
2222 length = undefined
2223 }
2224 } else {
2225 throw new Error(
2226 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
2227 )
2228 }
2229
2230 var remaining = this.length - offset
2231 if (length === undefined || length > remaining) length = remaining
2232
2233 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
2234 throw new RangeError('Attempt to write outside buffer bounds')
2235 }
2236
2237 if (!encoding) encoding = 'utf8'
2238
2239 var loweredCase = false
2240 for (;;) {
2241 switch (encoding) {
2242 case 'hex':
2243 return hexWrite(this, string, offset, length)
2244
2245 case 'utf8':
2246 case 'utf-8':
2247 return utf8Write(this, string, offset, length)
2248
2249 case 'ascii':
2250 return asciiWrite(this, string, offset, length)
2251
2252 case 'latin1':
2253 case 'binary':
2254 return latin1Write(this, string, offset, length)
2255
2256 case 'base64':
2257 // Warning: maxLength not taken into account in base64Write
2258 return base64Write(this, string, offset, length)
2259
2260 case 'ucs2':
2261 case 'ucs-2':
2262 case 'utf16le':
2263 case 'utf-16le':
2264 return ucs2Write(this, string, offset, length)
2265
2266 default:
2267 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
2268 encoding = ('' + encoding).toLowerCase()
2269 loweredCase = true
2270 }
2271 }
2272}
2273
2274Buffer.prototype.toJSON = function toJSON () {
2275 return {
2276 type: 'Buffer',
2277 data: Array.prototype.slice.call(this._arr || this, 0)
2278 }
2279}
2280
2281function base64Slice (buf, start, end) {
2282 if (start === 0 && end === buf.length) {
2283 return base64.fromByteArray(buf)
2284 } else {
2285 return base64.fromByteArray(buf.slice(start, end))
2286 }
2287}
2288
2289function utf8Slice (buf, start, end) {
2290 end = Math.min(buf.length, end)
2291 var res = []
2292
2293 var i = start
2294 while (i < end) {
2295 var firstByte = buf[i]
2296 var codePoint = null
2297 var bytesPerSequence = (firstByte > 0xEF) ? 4
2298 : (firstByte > 0xDF) ? 3
2299 : (firstByte > 0xBF) ? 2
2300 : 1
2301
2302 if (i + bytesPerSequence <= end) {
2303 var secondByte, thirdByte, fourthByte, tempCodePoint
2304
2305 switch (bytesPerSequence) {
2306 case 1:
2307 if (firstByte < 0x80) {
2308 codePoint = firstByte
2309 }
2310 break
2311 case 2:
2312 secondByte = buf[i + 1]
2313 if ((secondByte & 0xC0) === 0x80) {
2314 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
2315 if (tempCodePoint > 0x7F) {
2316 codePoint = tempCodePoint
2317 }
2318 }
2319 break
2320 case 3:
2321 secondByte = buf[i + 1]
2322 thirdByte = buf[i + 2]
2323 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
2324 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
2325 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
2326 codePoint = tempCodePoint
2327 }
2328 }
2329 break
2330 case 4:
2331 secondByte = buf[i + 1]
2332 thirdByte = buf[i + 2]
2333 fourthByte = buf[i + 3]
2334 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
2335 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
2336 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
2337 codePoint = tempCodePoint
2338 }
2339 }
2340 }
2341 }
2342
2343 if (codePoint === null) {
2344 // we did not generate a valid codePoint so insert a
2345 // replacement char (U+FFFD) and advance only 1 byte
2346 codePoint = 0xFFFD
2347 bytesPerSequence = 1
2348 } else if (codePoint > 0xFFFF) {
2349 // encode to utf16 (surrogate pair dance)
2350 codePoint -= 0x10000
2351 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
2352 codePoint = 0xDC00 | codePoint & 0x3FF
2353 }
2354
2355 res.push(codePoint)
2356 i += bytesPerSequence
2357 }
2358
2359 return decodeCodePointsArray(res)
2360}
2361
2362// Based on http://stackoverflow.com/a/22747272/680742, the browser with
2363// the lowest limit is Chrome, with 0x10000 args.
2364// We go 1 magnitude less, for safety
2365var MAX_ARGUMENTS_LENGTH = 0x1000
2366
2367function decodeCodePointsArray (codePoints) {
2368 var len = codePoints.length
2369 if (len <= MAX_ARGUMENTS_LENGTH) {
2370 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
2371 }
2372
2373 // Decode in chunks to avoid "call stack size exceeded".
2374 var res = ''
2375 var i = 0
2376 while (i < len) {
2377 res += String.fromCharCode.apply(
2378 String,
2379 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
2380 )
2381 }
2382 return res
2383}
2384
2385function asciiSlice (buf, start, end) {
2386 var ret = ''
2387 end = Math.min(buf.length, end)
2388
2389 for (var i = start; i < end; ++i) {
2390 ret += String.fromCharCode(buf[i] & 0x7F)
2391 }
2392 return ret
2393}
2394
2395function latin1Slice (buf, start, end) {
2396 var ret = ''
2397 end = Math.min(buf.length, end)
2398
2399 for (var i = start; i < end; ++i) {
2400 ret += String.fromCharCode(buf[i])
2401 }
2402 return ret
2403}
2404
2405function hexSlice (buf, start, end) {
2406 var len = buf.length
2407
2408 if (!start || start < 0) start = 0
2409 if (!end || end < 0 || end > len) end = len
2410
2411 var out = ''
2412 for (var i = start; i < end; ++i) {
2413 out += toHex(buf[i])
2414 }
2415 return out
2416}
2417
2418function utf16leSlice (buf, start, end) {
2419 var bytes = buf.slice(start, end)
2420 var res = ''
2421 for (var i = 0; i < bytes.length; i += 2) {
2422 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
2423 }
2424 return res
2425}
2426
2427Buffer.prototype.slice = function slice (start, end) {
2428 var len = this.length
2429 start = ~~start
2430 end = end === undefined ? len : ~~end
2431
2432 if (start < 0) {
2433 start += len
2434 if (start < 0) start = 0
2435 } else if (start > len) {
2436 start = len
2437 }
2438
2439 if (end < 0) {
2440 end += len
2441 if (end < 0) end = 0
2442 } else if (end > len) {
2443 end = len
2444 }
2445
2446 if (end < start) end = start
2447
2448 var newBuf = this.subarray(start, end)
2449 // Return an augmented `Uint8Array` instance
2450 newBuf.__proto__ = Buffer.prototype
2451 return newBuf
2452}
2453
2454/*
2455 * Need to make sure that buffer isn't trying to write out of bounds.
2456 */
2457function checkOffset (offset, ext, length) {
2458 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
2459 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
2460}
2461
2462Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
2463 offset = offset >>> 0
2464 byteLength = byteLength >>> 0
2465 if (!noAssert) checkOffset(offset, byteLength, this.length)
2466
2467 var val = this[offset]
2468 var mul = 1
2469 var i = 0
2470 while (++i < byteLength && (mul *= 0x100)) {
2471 val += this[offset + i] * mul
2472 }
2473
2474 return val
2475}
2476
2477Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
2478 offset = offset >>> 0
2479 byteLength = byteLength >>> 0
2480 if (!noAssert) {
2481 checkOffset(offset, byteLength, this.length)
2482 }
2483
2484 var val = this[offset + --byteLength]
2485 var mul = 1
2486 while (byteLength > 0 && (mul *= 0x100)) {
2487 val += this[offset + --byteLength] * mul
2488 }
2489
2490 return val
2491}
2492
2493Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
2494 offset = offset >>> 0
2495 if (!noAssert) checkOffset(offset, 1, this.length)
2496 return this[offset]
2497}
2498
2499Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
2500 offset = offset >>> 0
2501 if (!noAssert) checkOffset(offset, 2, this.length)
2502 return this[offset] | (this[offset + 1] << 8)
2503}
2504
2505Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
2506 offset = offset >>> 0
2507 if (!noAssert) checkOffset(offset, 2, this.length)
2508 return (this[offset] << 8) | this[offset + 1]
2509}
2510
2511Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
2512 offset = offset >>> 0
2513 if (!noAssert) checkOffset(offset, 4, this.length)
2514
2515 return ((this[offset]) |
2516 (this[offset + 1] << 8) |
2517 (this[offset + 2] << 16)) +
2518 (this[offset + 3] * 0x1000000)
2519}
2520
2521Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
2522 offset = offset >>> 0
2523 if (!noAssert) checkOffset(offset, 4, this.length)
2524
2525 return (this[offset] * 0x1000000) +
2526 ((this[offset + 1] << 16) |
2527 (this[offset + 2] << 8) |
2528 this[offset + 3])
2529}
2530
2531Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
2532 offset = offset >>> 0
2533 byteLength = byteLength >>> 0
2534 if (!noAssert) checkOffset(offset, byteLength, this.length)
2535
2536 var val = this[offset]
2537 var mul = 1
2538 var i = 0
2539 while (++i < byteLength && (mul *= 0x100)) {
2540 val += this[offset + i] * mul
2541 }
2542 mul *= 0x80
2543
2544 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
2545
2546 return val
2547}
2548
2549Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
2550 offset = offset >>> 0
2551 byteLength = byteLength >>> 0
2552 if (!noAssert) checkOffset(offset, byteLength, this.length)
2553
2554 var i = byteLength
2555 var mul = 1
2556 var val = this[offset + --i]
2557 while (i > 0 && (mul *= 0x100)) {
2558 val += this[offset + --i] * mul
2559 }
2560 mul *= 0x80
2561
2562 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
2563
2564 return val
2565}
2566
2567Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
2568 offset = offset >>> 0
2569 if (!noAssert) checkOffset(offset, 1, this.length)
2570 if (!(this[offset] & 0x80)) return (this[offset])
2571 return ((0xff - this[offset] + 1) * -1)
2572}
2573
2574Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
2575 offset = offset >>> 0
2576 if (!noAssert) checkOffset(offset, 2, this.length)
2577 var val = this[offset] | (this[offset + 1] << 8)
2578 return (val & 0x8000) ? val | 0xFFFF0000 : val
2579}
2580
2581Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
2582 offset = offset >>> 0
2583 if (!noAssert) checkOffset(offset, 2, this.length)
2584 var val = this[offset + 1] | (this[offset] << 8)
2585 return (val & 0x8000) ? val | 0xFFFF0000 : val
2586}
2587
2588Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
2589 offset = offset >>> 0
2590 if (!noAssert) checkOffset(offset, 4, this.length)
2591
2592 return (this[offset]) |
2593 (this[offset + 1] << 8) |
2594 (this[offset + 2] << 16) |
2595 (this[offset + 3] << 24)
2596}
2597
2598Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
2599 offset = offset >>> 0
2600 if (!noAssert) checkOffset(offset, 4, this.length)
2601
2602 return (this[offset] << 24) |
2603 (this[offset + 1] << 16) |
2604 (this[offset + 2] << 8) |
2605 (this[offset + 3])
2606}
2607
2608Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
2609 offset = offset >>> 0
2610 if (!noAssert) checkOffset(offset, 4, this.length)
2611 return ieee754.read(this, offset, true, 23, 4)
2612}
2613
2614Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
2615 offset = offset >>> 0
2616 if (!noAssert) checkOffset(offset, 4, this.length)
2617 return ieee754.read(this, offset, false, 23, 4)
2618}
2619
2620Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
2621 offset = offset >>> 0
2622 if (!noAssert) checkOffset(offset, 8, this.length)
2623 return ieee754.read(this, offset, true, 52, 8)
2624}
2625
2626Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
2627 offset = offset >>> 0
2628 if (!noAssert) checkOffset(offset, 8, this.length)
2629 return ieee754.read(this, offset, false, 52, 8)
2630}
2631
2632function checkInt (buf, value, offset, ext, max, min) {
2633 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
2634 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
2635 if (offset + ext > buf.length) throw new RangeError('Index out of range')
2636}
2637
2638Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
2639 value = +value
2640 offset = offset >>> 0
2641 byteLength = byteLength >>> 0
2642 if (!noAssert) {
2643 var maxBytes = Math.pow(2, 8 * byteLength) - 1
2644 checkInt(this, value, offset, byteLength, maxBytes, 0)
2645 }
2646
2647 var mul = 1
2648 var i = 0
2649 this[offset] = value & 0xFF
2650 while (++i < byteLength && (mul *= 0x100)) {
2651 this[offset + i] = (value / mul) & 0xFF
2652 }
2653
2654 return offset + byteLength
2655}
2656
2657Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
2658 value = +value
2659 offset = offset >>> 0
2660 byteLength = byteLength >>> 0
2661 if (!noAssert) {
2662 var maxBytes = Math.pow(2, 8 * byteLength) - 1
2663 checkInt(this, value, offset, byteLength, maxBytes, 0)
2664 }
2665
2666 var i = byteLength - 1
2667 var mul = 1
2668 this[offset + i] = value & 0xFF
2669 while (--i >= 0 && (mul *= 0x100)) {
2670 this[offset + i] = (value / mul) & 0xFF
2671 }
2672
2673 return offset + byteLength
2674}
2675
2676Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
2677 value = +value
2678 offset = offset >>> 0
2679 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
2680 this[offset] = (value & 0xff)
2681 return offset + 1
2682}
2683
2684Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
2685 value = +value
2686 offset = offset >>> 0
2687 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
2688 this[offset] = (value & 0xff)
2689 this[offset + 1] = (value >>> 8)
2690 return offset + 2
2691}
2692
2693Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
2694 value = +value
2695 offset = offset >>> 0
2696 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
2697 this[offset] = (value >>> 8)
2698 this[offset + 1] = (value & 0xff)
2699 return offset + 2
2700}
2701
2702Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
2703 value = +value
2704 offset = offset >>> 0
2705 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
2706 this[offset + 3] = (value >>> 24)
2707 this[offset + 2] = (value >>> 16)
2708 this[offset + 1] = (value >>> 8)
2709 this[offset] = (value & 0xff)
2710 return offset + 4
2711}
2712
2713Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
2714 value = +value
2715 offset = offset >>> 0
2716 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
2717 this[offset] = (value >>> 24)
2718 this[offset + 1] = (value >>> 16)
2719 this[offset + 2] = (value >>> 8)
2720 this[offset + 3] = (value & 0xff)
2721 return offset + 4
2722}
2723
2724Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
2725 value = +value
2726 offset = offset >>> 0
2727 if (!noAssert) {
2728 var limit = Math.pow(2, (8 * byteLength) - 1)
2729
2730 checkInt(this, value, offset, byteLength, limit - 1, -limit)
2731 }
2732
2733 var i = 0
2734 var mul = 1
2735 var sub = 0
2736 this[offset] = value & 0xFF
2737 while (++i < byteLength && (mul *= 0x100)) {
2738 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
2739 sub = 1
2740 }
2741 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
2742 }
2743
2744 return offset + byteLength
2745}
2746
2747Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
2748 value = +value
2749 offset = offset >>> 0
2750 if (!noAssert) {
2751 var limit = Math.pow(2, (8 * byteLength) - 1)
2752
2753 checkInt(this, value, offset, byteLength, limit - 1, -limit)
2754 }
2755
2756 var i = byteLength - 1
2757 var mul = 1
2758 var sub = 0
2759 this[offset + i] = value & 0xFF
2760 while (--i >= 0 && (mul *= 0x100)) {
2761 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
2762 sub = 1
2763 }
2764 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
2765 }
2766
2767 return offset + byteLength
2768}
2769
2770Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
2771 value = +value
2772 offset = offset >>> 0
2773 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
2774 if (value < 0) value = 0xff + value + 1
2775 this[offset] = (value & 0xff)
2776 return offset + 1
2777}
2778
2779Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
2780 value = +value
2781 offset = offset >>> 0
2782 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2783 this[offset] = (value & 0xff)
2784 this[offset + 1] = (value >>> 8)
2785 return offset + 2
2786}
2787
2788Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2789 value = +value
2790 offset = offset >>> 0
2791 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2792 this[offset] = (value >>> 8)
2793 this[offset + 1] = (value & 0xff)
2794 return offset + 2
2795}
2796
2797Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2798 value = +value
2799 offset = offset >>> 0
2800 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2801 this[offset] = (value & 0xff)
2802 this[offset + 1] = (value >>> 8)
2803 this[offset + 2] = (value >>> 16)
2804 this[offset + 3] = (value >>> 24)
2805 return offset + 4
2806}
2807
2808Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2809 value = +value
2810 offset = offset >>> 0
2811 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2812 if (value < 0) value = 0xffffffff + value + 1
2813 this[offset] = (value >>> 24)
2814 this[offset + 1] = (value >>> 16)
2815 this[offset + 2] = (value >>> 8)
2816 this[offset + 3] = (value & 0xff)
2817 return offset + 4
2818}
2819
2820function checkIEEE754 (buf, value, offset, ext, max, min) {
2821 if (offset + ext > buf.length) throw new RangeError('Index out of range')
2822 if (offset < 0) throw new RangeError('Index out of range')
2823}
2824
2825function writeFloat (buf, value, offset, littleEndian, noAssert) {
2826 value = +value
2827 offset = offset >>> 0
2828 if (!noAssert) {
2829 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
2830 }
2831 ieee754.write(buf, value, offset, littleEndian, 23, 4)
2832 return offset + 4
2833}
2834
2835Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2836 return writeFloat(this, value, offset, true, noAssert)
2837}
2838
2839Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2840 return writeFloat(this, value, offset, false, noAssert)
2841}
2842
2843function writeDouble (buf, value, offset, littleEndian, noAssert) {
2844 value = +value
2845 offset = offset >>> 0
2846 if (!noAssert) {
2847 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
2848 }
2849 ieee754.write(buf, value, offset, littleEndian, 52, 8)
2850 return offset + 8
2851}
2852
2853Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2854 return writeDouble(this, value, offset, true, noAssert)
2855}
2856
2857Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2858 return writeDouble(this, value, offset, false, noAssert)
2859}
2860
2861// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2862Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2863 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
2864 if (!start) start = 0
2865 if (!end && end !== 0) end = this.length
2866 if (targetStart >= target.length) targetStart = target.length
2867 if (!targetStart) targetStart = 0
2868 if (end > 0 && end < start) end = start
2869
2870 // Copy 0 bytes; we're done
2871 if (end === start) return 0
2872 if (target.length === 0 || this.length === 0) return 0
2873
2874 // Fatal error conditions
2875 if (targetStart < 0) {
2876 throw new RangeError('targetStart out of bounds')
2877 }
2878 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
2879 if (end < 0) throw new RangeError('sourceEnd out of bounds')
2880
2881 // Are we oob?
2882 if (end > this.length) end = this.length
2883 if (target.length - targetStart < end - start) {
2884 end = target.length - targetStart + start
2885 }
2886
2887 var len = end - start
2888
2889 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
2890 // Use built-in when available, missing from IE11
2891 this.copyWithin(targetStart, start, end)
2892 } else if (this === target && start < targetStart && targetStart < end) {
2893 // descending copy from end
2894 for (var i = len - 1; i >= 0; --i) {
2895 target[i + targetStart] = this[i + start]
2896 }
2897 } else {
2898 Uint8Array.prototype.set.call(
2899 target,
2900 this.subarray(start, end),
2901 targetStart
2902 )
2903 }
2904
2905 return len
2906}
2907
2908// Usage:
2909// buffer.fill(number[, offset[, end]])
2910// buffer.fill(buffer[, offset[, end]])
2911// buffer.fill(string[, offset[, end]][, encoding])
2912Buffer.prototype.fill = function fill (val, start, end, encoding) {
2913 // Handle string cases:
2914 if (typeof val === 'string') {
2915 if (typeof start === 'string') {
2916 encoding = start
2917 start = 0
2918 end = this.length
2919 } else if (typeof end === 'string') {
2920 encoding = end
2921 end = this.length
2922 }
2923 if (encoding !== undefined && typeof encoding !== 'string') {
2924 throw new TypeError('encoding must be a string')
2925 }
2926 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2927 throw new TypeError('Unknown encoding: ' + encoding)
2928 }
2929 if (val.length === 1) {
2930 var code = val.charCodeAt(0)
2931 if ((encoding === 'utf8' && code < 128) ||
2932 encoding === 'latin1') {
2933 // Fast path: If `val` fits into a single byte, use that numeric value.
2934 val = code
2935 }
2936 }
2937 } else if (typeof val === 'number') {
2938 val = val & 255
2939 }
2940
2941 // Invalid ranges are not set to a default, so can range check early.
2942 if (start < 0 || this.length < start || this.length < end) {
2943 throw new RangeError('Out of range index')
2944 }
2945
2946 if (end <= start) {
2947 return this
2948 }
2949
2950 start = start >>> 0
2951 end = end === undefined ? this.length : end >>> 0
2952
2953 if (!val) val = 0
2954
2955 var i
2956 if (typeof val === 'number') {
2957 for (i = start; i < end; ++i) {
2958 this[i] = val
2959 }
2960 } else {
2961 var bytes = Buffer.isBuffer(val)
2962 ? val
2963 : Buffer.from(val, encoding)
2964 var len = bytes.length
2965 if (len === 0) {
2966 throw new TypeError('The value "' + val +
2967 '" is invalid for argument "value"')
2968 }
2969 for (i = 0; i < end - start; ++i) {
2970 this[i + start] = bytes[i % len]
2971 }
2972 }
2973
2974 return this
2975}
2976
2977// HELPER FUNCTIONS
2978// ================
2979
2980var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
2981
2982function base64clean (str) {
2983 // Node takes equal signs as end of the Base64 encoding
2984 str = str.split('=')[0]
2985 // Node strips out invalid characters like \n and \t from the string, base64-js does not
2986 str = str.trim().replace(INVALID_BASE64_RE, '')
2987 // Node converts strings with length < 2 to ''
2988 if (str.length < 2) return ''
2989 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2990 while (str.length % 4 !== 0) {
2991 str = str + '='
2992 }
2993 return str
2994}
2995
2996function toHex (n) {
2997 if (n < 16) return '0' + n.toString(16)
2998 return n.toString(16)
2999}
3000
3001function utf8ToBytes (string, units) {
3002 units = units || Infinity
3003 var codePoint
3004 var length = string.length
3005 var leadSurrogate = null
3006 var bytes = []
3007
3008 for (var i = 0; i < length; ++i) {
3009 codePoint = string.charCodeAt(i)
3010
3011 // is surrogate component
3012 if (codePoint > 0xD7FF && codePoint < 0xE000) {
3013 // last char was a lead
3014 if (!leadSurrogate) {
3015 // no lead yet
3016 if (codePoint > 0xDBFF) {
3017 // unexpected trail
3018 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
3019 continue
3020 } else if (i + 1 === length) {
3021 // unpaired lead
3022 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
3023 continue
3024 }
3025
3026 // valid lead
3027 leadSurrogate = codePoint
3028
3029 continue
3030 }
3031
3032 // 2 leads in a row
3033 if (codePoint < 0xDC00) {
3034 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
3035 leadSurrogate = codePoint
3036 continue
3037 }
3038
3039 // valid surrogate pair
3040 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
3041 } else if (leadSurrogate) {
3042 // valid bmp char, but last char was a lead
3043 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
3044 }
3045
3046 leadSurrogate = null
3047
3048 // encode utf8
3049 if (codePoint < 0x80) {
3050 if ((units -= 1) < 0) break
3051 bytes.push(codePoint)
3052 } else if (codePoint < 0x800) {
3053 if ((units -= 2) < 0) break
3054 bytes.push(
3055 codePoint >> 0x6 | 0xC0,
3056 codePoint & 0x3F | 0x80
3057 )
3058 } else if (codePoint < 0x10000) {
3059 if ((units -= 3) < 0) break
3060 bytes.push(
3061 codePoint >> 0xC | 0xE0,
3062 codePoint >> 0x6 & 0x3F | 0x80,
3063 codePoint & 0x3F | 0x80
3064 )
3065 } else if (codePoint < 0x110000) {
3066 if ((units -= 4) < 0) break
3067 bytes.push(
3068 codePoint >> 0x12 | 0xF0,
3069 codePoint >> 0xC & 0x3F | 0x80,
3070 codePoint >> 0x6 & 0x3F | 0x80,
3071 codePoint & 0x3F | 0x80
3072 )
3073 } else {
3074 throw new Error('Invalid code point')
3075 }
3076 }
3077
3078 return bytes
3079}
3080
3081function asciiToBytes (str) {
3082 var byteArray = []
3083 for (var i = 0; i < str.length; ++i) {
3084 // Node's code seems to be doing this and not & 0x7F..
3085 byteArray.push(str.charCodeAt(i) & 0xFF)
3086 }
3087 return byteArray
3088}
3089
3090function utf16leToBytes (str, units) {
3091 var c, hi, lo
3092 var byteArray = []
3093 for (var i = 0; i < str.length; ++i) {
3094 if ((units -= 2) < 0) break
3095
3096 c = str.charCodeAt(i)
3097 hi = c >> 8
3098 lo = c % 256
3099 byteArray.push(lo)
3100 byteArray.push(hi)
3101 }
3102
3103 return byteArray
3104}
3105
3106function base64ToBytes (str) {
3107 return base64.toByteArray(base64clean(str))
3108}
3109
3110function blitBuffer (src, dst, offset, length) {
3111 for (var i = 0; i < length; ++i) {
3112 if ((i + offset >= dst.length) || (i >= src.length)) break
3113 dst[i + offset] = src[i]
3114 }
3115 return i
3116}
3117
3118// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
3119// the `instanceof` check but they should be treated as of that type.
3120// See: https://github.com/feross/buffer/issues/166
3121function isInstance (obj, type) {
3122 return obj instanceof type ||
3123 (obj != null && obj.constructor != null && obj.constructor.name != null &&
3124 obj.constructor.name === type.name)
3125}
3126function numberIsNaN (obj) {
3127 // For IE11 support
3128 return obj !== obj // eslint-disable-line no-self-compare
3129}
3130
3131},{"base64-js":6,"ieee754":67}],10:[function(require,module,exports){
3132module.exports = {
3133 "100": "Continue",
3134 "101": "Switching Protocols",
3135 "102": "Processing",
3136 "200": "OK",
3137 "201": "Created",
3138 "202": "Accepted",
3139 "203": "Non-Authoritative Information",
3140 "204": "No Content",
3141 "205": "Reset Content",
3142 "206": "Partial Content",
3143 "207": "Multi-Status",
3144 "208": "Already Reported",
3145 "226": "IM Used",
3146 "300": "Multiple Choices",
3147 "301": "Moved Permanently",
3148 "302": "Found",
3149 "303": "See Other",
3150 "304": "Not Modified",
3151 "305": "Use Proxy",
3152 "307": "Temporary Redirect",
3153 "308": "Permanent Redirect",
3154 "400": "Bad Request",
3155 "401": "Unauthorized",
3156 "402": "Payment Required",
3157 "403": "Forbidden",
3158 "404": "Not Found",
3159 "405": "Method Not Allowed",
3160 "406": "Not Acceptable",
3161 "407": "Proxy Authentication Required",
3162 "408": "Request Timeout",
3163 "409": "Conflict",
3164 "410": "Gone",
3165 "411": "Length Required",
3166 "412": "Precondition Failed",
3167 "413": "Payload Too Large",
3168 "414": "URI Too Long",
3169 "415": "Unsupported Media Type",
3170 "416": "Range Not Satisfiable",
3171 "417": "Expectation Failed",
3172 "418": "I'm a teapot",
3173 "421": "Misdirected Request",
3174 "422": "Unprocessable Entity",
3175 "423": "Locked",
3176 "424": "Failed Dependency",
3177 "425": "Unordered Collection",
3178 "426": "Upgrade Required",
3179 "428": "Precondition Required",
3180 "429": "Too Many Requests",
3181 "431": "Request Header Fields Too Large",
3182 "451": "Unavailable For Legal Reasons",
3183 "500": "Internal Server Error",
3184 "501": "Not Implemented",
3185 "502": "Bad Gateway",
3186 "503": "Service Unavailable",
3187 "504": "Gateway Timeout",
3188 "505": "HTTP Version Not Supported",
3189 "506": "Variant Also Negotiates",
3190 "507": "Insufficient Storage",
3191 "508": "Loop Detected",
3192 "509": "Bandwidth Limit Exceeded",
3193 "510": "Not Extended",
3194 "511": "Network Authentication Required"
3195}
3196
3197},{}],11:[function(require,module,exports){
3198(function (process,global){
3199"use strict"
3200
3201var next = (global.process && process.nextTick) || global.setImmediate || function (f) {
3202 setTimeout(f, 0)
3203}
3204
3205module.exports = function maybe (cb, promise) {
3206 if (cb) {
3207 promise
3208 .then(function (result) {
3209 next(function () { cb(null, result) })
3210 }, function (err) {
3211 next(function () { cb(err) })
3212 })
3213 return undefined
3214 }
3215 else {
3216 return promise
3217 }
3218}
3219
3220}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3221
3222},{"_process":125}],12:[function(require,module,exports){
3223require('../modules/es6.symbol');
3224require('../modules/es6.object.to-string');
3225module.exports = require('../modules/_core').Symbol;
3226
3227},{"../modules/_core":18,"../modules/es6.object.to-string":61,"../modules/es6.symbol":62}],13:[function(require,module,exports){
3228module.exports = function (it) {
3229 if (typeof it != 'function') throw TypeError(it + ' is not a function!');
3230 return it;
3231};
3232
3233},{}],14:[function(require,module,exports){
3234var isObject = require('./_is-object');
3235module.exports = function (it) {
3236 if (!isObject(it)) throw TypeError(it + ' is not an object!');
3237 return it;
3238};
3239
3240},{"./_is-object":34}],15:[function(require,module,exports){
3241// false -> Array#indexOf
3242// true -> Array#includes
3243var toIObject = require('./_to-iobject');
3244var toLength = require('./_to-length');
3245var toAbsoluteIndex = require('./_to-absolute-index');
3246module.exports = function (IS_INCLUDES) {
3247 return function ($this, el, fromIndex) {
3248 var O = toIObject($this);
3249 var length = toLength(O.length);
3250 var index = toAbsoluteIndex(fromIndex, length);
3251 var value;
3252 // Array#includes uses SameValueZero equality algorithm
3253 // eslint-disable-next-line no-self-compare
3254 if (IS_INCLUDES && el != el) while (length > index) {
3255 value = O[index++];
3256 // eslint-disable-next-line no-self-compare
3257 if (value != value) return true;
3258 // Array#indexOf ignores holes, Array#includes - not
3259 } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
3260 if (O[index] === el) return IS_INCLUDES || index || 0;
3261 } return !IS_INCLUDES && -1;
3262 };
3263};
3264
3265},{"./_to-absolute-index":52,"./_to-iobject":54,"./_to-length":55}],16:[function(require,module,exports){
3266// getting tag from 19.1.3.6 Object.prototype.toString()
3267var cof = require('./_cof');
3268var TAG = require('./_wks')('toStringTag');
3269// ES3 wrong here
3270var ARG = cof(function () { return arguments; }()) == 'Arguments';
3271
3272// fallback for IE11 Script Access Denied error
3273var tryGet = function (it, key) {
3274 try {
3275 return it[key];
3276 } catch (e) { /* empty */ }
3277};
3278
3279module.exports = function (it) {
3280 var O, T, B;
3281 return it === undefined ? 'Undefined' : it === null ? 'Null'
3282 // @@toStringTag case
3283 : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
3284 // builtinTag case
3285 : ARG ? cof(O)
3286 // ES3 arguments fallback
3287 : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
3288};
3289
3290},{"./_cof":17,"./_wks":60}],17:[function(require,module,exports){
3291var toString = {}.toString;
3292
3293module.exports = function (it) {
3294 return toString.call(it).slice(8, -1);
3295};
3296
3297},{}],18:[function(require,module,exports){
3298var core = module.exports = { version: '2.6.3' };
3299if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
3300
3301},{}],19:[function(require,module,exports){
3302// optional / simple context binding
3303var aFunction = require('./_a-function');
3304module.exports = function (fn, that, length) {
3305 aFunction(fn);
3306 if (that === undefined) return fn;
3307 switch (length) {
3308 case 1: return function (a) {
3309 return fn.call(that, a);
3310 };
3311 case 2: return function (a, b) {
3312 return fn.call(that, a, b);
3313 };
3314 case 3: return function (a, b, c) {
3315 return fn.call(that, a, b, c);
3316 };
3317 }
3318 return function (/* ...args */) {
3319 return fn.apply(that, arguments);
3320 };
3321};
3322
3323},{"./_a-function":13}],20:[function(require,module,exports){
3324// 7.2.1 RequireObjectCoercible(argument)
3325module.exports = function (it) {
3326 if (it == undefined) throw TypeError("Can't call method on " + it);
3327 return it;
3328};
3329
3330},{}],21:[function(require,module,exports){
3331// Thank's IE8 for his funny defineProperty
3332module.exports = !require('./_fails')(function () {
3333 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
3334});
3335
3336},{"./_fails":26}],22:[function(require,module,exports){
3337var isObject = require('./_is-object');
3338var document = require('./_global').document;
3339// typeof document.createElement is 'object' in old IE
3340var is = isObject(document) && isObject(document.createElement);
3341module.exports = function (it) {
3342 return is ? document.createElement(it) : {};
3343};
3344
3345},{"./_global":27,"./_is-object":34}],23:[function(require,module,exports){
3346// IE 8- don't enum bug keys
3347module.exports = (
3348 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
3349).split(',');
3350
3351},{}],24:[function(require,module,exports){
3352// all enumerable object keys, includes symbols
3353var getKeys = require('./_object-keys');
3354var gOPS = require('./_object-gops');
3355var pIE = require('./_object-pie');
3356module.exports = function (it) {
3357 var result = getKeys(it);
3358 var getSymbols = gOPS.f;
3359 if (getSymbols) {
3360 var symbols = getSymbols(it);
3361 var isEnum = pIE.f;
3362 var i = 0;
3363 var key;
3364 while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
3365 } return result;
3366};
3367
3368},{"./_object-gops":43,"./_object-keys":45,"./_object-pie":46}],25:[function(require,module,exports){
3369var global = require('./_global');
3370var core = require('./_core');
3371var hide = require('./_hide');
3372var redefine = require('./_redefine');
3373var ctx = require('./_ctx');
3374var PROTOTYPE = 'prototype';
3375
3376var $export = function (type, name, source) {
3377 var IS_FORCED = type & $export.F;
3378 var IS_GLOBAL = type & $export.G;
3379 var IS_STATIC = type & $export.S;
3380 var IS_PROTO = type & $export.P;
3381 var IS_BIND = type & $export.B;
3382 var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
3383 var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
3384 var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
3385 var key, own, out, exp;
3386 if (IS_GLOBAL) source = name;
3387 for (key in source) {
3388 // contains in native
3389 own = !IS_FORCED && target && target[key] !== undefined;
3390 // export native or passed
3391 out = (own ? target : source)[key];
3392 // bind timers to global for call from export context
3393 exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
3394 // extend global
3395 if (target) redefine(target, key, out, type & $export.U);
3396 // export
3397 if (exports[key] != out) hide(exports, key, exp);
3398 if (IS_PROTO && expProto[key] != out) expProto[key] = out;
3399 }
3400};
3401global.core = core;
3402// type bitmap
3403$export.F = 1; // forced
3404$export.G = 2; // global
3405$export.S = 4; // static
3406$export.P = 8; // proto
3407$export.B = 16; // bind
3408$export.W = 32; // wrap
3409$export.U = 64; // safe
3410$export.R = 128; // real proto method for `library`
3411module.exports = $export;
3412
3413},{"./_core":18,"./_ctx":19,"./_global":27,"./_hide":29,"./_redefine":48}],26:[function(require,module,exports){
3414module.exports = function (exec) {
3415 try {
3416 return !!exec();
3417 } catch (e) {
3418 return true;
3419 }
3420};
3421
3422},{}],27:[function(require,module,exports){
3423// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
3424var global = module.exports = typeof window != 'undefined' && window.Math == Math
3425 ? window : typeof self != 'undefined' && self.Math == Math ? self
3426 // eslint-disable-next-line no-new-func
3427 : Function('return this')();
3428if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
3429
3430},{}],28:[function(require,module,exports){
3431var hasOwnProperty = {}.hasOwnProperty;
3432module.exports = function (it, key) {
3433 return hasOwnProperty.call(it, key);
3434};
3435
3436},{}],29:[function(require,module,exports){
3437var dP = require('./_object-dp');
3438var createDesc = require('./_property-desc');
3439module.exports = require('./_descriptors') ? function (object, key, value) {
3440 return dP.f(object, key, createDesc(1, value));
3441} : function (object, key, value) {
3442 object[key] = value;
3443 return object;
3444};
3445
3446},{"./_descriptors":21,"./_object-dp":38,"./_property-desc":47}],30:[function(require,module,exports){
3447var document = require('./_global').document;
3448module.exports = document && document.documentElement;
3449
3450},{"./_global":27}],31:[function(require,module,exports){
3451module.exports = !require('./_descriptors') && !require('./_fails')(function () {
3452 return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
3453});
3454
3455},{"./_descriptors":21,"./_dom-create":22,"./_fails":26}],32:[function(require,module,exports){
3456// fallback for non-array-like ES3 and non-enumerable old V8 strings
3457var cof = require('./_cof');
3458// eslint-disable-next-line no-prototype-builtins
3459module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
3460 return cof(it) == 'String' ? it.split('') : Object(it);
3461};
3462
3463},{"./_cof":17}],33:[function(require,module,exports){
3464// 7.2.2 IsArray(argument)
3465var cof = require('./_cof');
3466module.exports = Array.isArray || function isArray(arg) {
3467 return cof(arg) == 'Array';
3468};
3469
3470},{"./_cof":17}],34:[function(require,module,exports){
3471module.exports = function (it) {
3472 return typeof it === 'object' ? it !== null : typeof it === 'function';
3473};
3474
3475},{}],35:[function(require,module,exports){
3476module.exports = false;
3477
3478},{}],36:[function(require,module,exports){
3479var META = require('./_uid')('meta');
3480var isObject = require('./_is-object');
3481var has = require('./_has');
3482var setDesc = require('./_object-dp').f;
3483var id = 0;
3484var isExtensible = Object.isExtensible || function () {
3485 return true;
3486};
3487var FREEZE = !require('./_fails')(function () {
3488 return isExtensible(Object.preventExtensions({}));
3489});
3490var setMeta = function (it) {
3491 setDesc(it, META, { value: {
3492 i: 'O' + ++id, // object ID
3493 w: {} // weak collections IDs
3494 } });
3495};
3496var fastKey = function (it, create) {
3497 // return primitive with prefix
3498 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
3499 if (!has(it, META)) {
3500 // can't set metadata to uncaught frozen object
3501 if (!isExtensible(it)) return 'F';
3502 // not necessary to add metadata
3503 if (!create) return 'E';
3504 // add missing metadata
3505 setMeta(it);
3506 // return object ID
3507 } return it[META].i;
3508};
3509var getWeak = function (it, create) {
3510 if (!has(it, META)) {
3511 // can't set metadata to uncaught frozen object
3512 if (!isExtensible(it)) return true;
3513 // not necessary to add metadata
3514 if (!create) return false;
3515 // add missing metadata
3516 setMeta(it);
3517 // return hash weak collections IDs
3518 } return it[META].w;
3519};
3520// add metadata on freeze-family methods calling
3521var onFreeze = function (it) {
3522 if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
3523 return it;
3524};
3525var meta = module.exports = {
3526 KEY: META,
3527 NEED: false,
3528 fastKey: fastKey,
3529 getWeak: getWeak,
3530 onFreeze: onFreeze
3531};
3532
3533},{"./_fails":26,"./_has":28,"./_is-object":34,"./_object-dp":38,"./_uid":57}],37:[function(require,module,exports){
3534// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
3535var anObject = require('./_an-object');
3536var dPs = require('./_object-dps');
3537var enumBugKeys = require('./_enum-bug-keys');
3538var IE_PROTO = require('./_shared-key')('IE_PROTO');
3539var Empty = function () { /* empty */ };
3540var PROTOTYPE = 'prototype';
3541
3542// Create object with fake `null` prototype: use iframe Object with cleared prototype
3543var createDict = function () {
3544 // Thrash, waste and sodomy: IE GC bug
3545 var iframe = require('./_dom-create')('iframe');
3546 var i = enumBugKeys.length;
3547 var lt = '<';
3548 var gt = '>';
3549 var iframeDocument;
3550 iframe.style.display = 'none';
3551 require('./_html').appendChild(iframe);
3552 iframe.src = 'javascript:'; // eslint-disable-line no-script-url
3553 // createDict = iframe.contentWindow.Object;
3554 // html.removeChild(iframe);
3555 iframeDocument = iframe.contentWindow.document;
3556 iframeDocument.open();
3557 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
3558 iframeDocument.close();
3559 createDict = iframeDocument.F;
3560 while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
3561 return createDict();
3562};
3563
3564module.exports = Object.create || function create(O, Properties) {
3565 var result;
3566 if (O !== null) {
3567 Empty[PROTOTYPE] = anObject(O);
3568 result = new Empty();
3569 Empty[PROTOTYPE] = null;
3570 // add "__proto__" for Object.getPrototypeOf polyfill
3571 result[IE_PROTO] = O;
3572 } else result = createDict();
3573 return Properties === undefined ? result : dPs(result, Properties);
3574};
3575
3576},{"./_an-object":14,"./_dom-create":22,"./_enum-bug-keys":23,"./_html":30,"./_object-dps":39,"./_shared-key":50}],38:[function(require,module,exports){
3577var anObject = require('./_an-object');
3578var IE8_DOM_DEFINE = require('./_ie8-dom-define');
3579var toPrimitive = require('./_to-primitive');
3580var dP = Object.defineProperty;
3581
3582exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
3583 anObject(O);
3584 P = toPrimitive(P, true);
3585 anObject(Attributes);
3586 if (IE8_DOM_DEFINE) try {
3587 return dP(O, P, Attributes);
3588 } catch (e) { /* empty */ }
3589 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
3590 if ('value' in Attributes) O[P] = Attributes.value;
3591 return O;
3592};
3593
3594},{"./_an-object":14,"./_descriptors":21,"./_ie8-dom-define":31,"./_to-primitive":56}],39:[function(require,module,exports){
3595var dP = require('./_object-dp');
3596var anObject = require('./_an-object');
3597var getKeys = require('./_object-keys');
3598
3599module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
3600 anObject(O);
3601 var keys = getKeys(Properties);
3602 var length = keys.length;
3603 var i = 0;
3604 var P;
3605 while (length > i) dP.f(O, P = keys[i++], Properties[P]);
3606 return O;
3607};
3608
3609},{"./_an-object":14,"./_descriptors":21,"./_object-dp":38,"./_object-keys":45}],40:[function(require,module,exports){
3610var pIE = require('./_object-pie');
3611var createDesc = require('./_property-desc');
3612var toIObject = require('./_to-iobject');
3613var toPrimitive = require('./_to-primitive');
3614var has = require('./_has');
3615var IE8_DOM_DEFINE = require('./_ie8-dom-define');
3616var gOPD = Object.getOwnPropertyDescriptor;
3617
3618exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {
3619 O = toIObject(O);
3620 P = toPrimitive(P, true);
3621 if (IE8_DOM_DEFINE) try {
3622 return gOPD(O, P);
3623 } catch (e) { /* empty */ }
3624 if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
3625};
3626
3627},{"./_descriptors":21,"./_has":28,"./_ie8-dom-define":31,"./_object-pie":46,"./_property-desc":47,"./_to-iobject":54,"./_to-primitive":56}],41:[function(require,module,exports){
3628// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
3629var toIObject = require('./_to-iobject');
3630var gOPN = require('./_object-gopn').f;
3631var toString = {}.toString;
3632
3633var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
3634 ? Object.getOwnPropertyNames(window) : [];
3635
3636var getWindowNames = function (it) {
3637 try {
3638 return gOPN(it);
3639 } catch (e) {
3640 return windowNames.slice();
3641 }
3642};
3643
3644module.exports.f = function getOwnPropertyNames(it) {
3645 return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
3646};
3647
3648},{"./_object-gopn":42,"./_to-iobject":54}],42:[function(require,module,exports){
3649// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
3650var $keys = require('./_object-keys-internal');
3651var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
3652
3653exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
3654 return $keys(O, hiddenKeys);
3655};
3656
3657},{"./_enum-bug-keys":23,"./_object-keys-internal":44}],43:[function(require,module,exports){
3658exports.f = Object.getOwnPropertySymbols;
3659
3660},{}],44:[function(require,module,exports){
3661var has = require('./_has');
3662var toIObject = require('./_to-iobject');
3663var arrayIndexOf = require('./_array-includes')(false);
3664var IE_PROTO = require('./_shared-key')('IE_PROTO');
3665
3666module.exports = function (object, names) {
3667 var O = toIObject(object);
3668 var i = 0;
3669 var result = [];
3670 var key;
3671 for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
3672 // Don't enum bug & hidden keys
3673 while (names.length > i) if (has(O, key = names[i++])) {
3674 ~arrayIndexOf(result, key) || result.push(key);
3675 }
3676 return result;
3677};
3678
3679},{"./_array-includes":15,"./_has":28,"./_shared-key":50,"./_to-iobject":54}],45:[function(require,module,exports){
3680// 19.1.2.14 / 15.2.3.14 Object.keys(O)
3681var $keys = require('./_object-keys-internal');
3682var enumBugKeys = require('./_enum-bug-keys');
3683
3684module.exports = Object.keys || function keys(O) {
3685 return $keys(O, enumBugKeys);
3686};
3687
3688},{"./_enum-bug-keys":23,"./_object-keys-internal":44}],46:[function(require,module,exports){
3689exports.f = {}.propertyIsEnumerable;
3690
3691},{}],47:[function(require,module,exports){
3692module.exports = function (bitmap, value) {
3693 return {
3694 enumerable: !(bitmap & 1),
3695 configurable: !(bitmap & 2),
3696 writable: !(bitmap & 4),
3697 value: value
3698 };
3699};
3700
3701},{}],48:[function(require,module,exports){
3702var global = require('./_global');
3703var hide = require('./_hide');
3704var has = require('./_has');
3705var SRC = require('./_uid')('src');
3706var TO_STRING = 'toString';
3707var $toString = Function[TO_STRING];
3708var TPL = ('' + $toString).split(TO_STRING);
3709
3710require('./_core').inspectSource = function (it) {
3711 return $toString.call(it);
3712};
3713
3714(module.exports = function (O, key, val, safe) {
3715 var isFunction = typeof val == 'function';
3716 if (isFunction) has(val, 'name') || hide(val, 'name', key);
3717 if (O[key] === val) return;
3718 if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
3719 if (O === global) {
3720 O[key] = val;
3721 } else if (!safe) {
3722 delete O[key];
3723 hide(O, key, val);
3724 } else if (O[key]) {
3725 O[key] = val;
3726 } else {
3727 hide(O, key, val);
3728 }
3729// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
3730})(Function.prototype, TO_STRING, function toString() {
3731 return typeof this == 'function' && this[SRC] || $toString.call(this);
3732});
3733
3734},{"./_core":18,"./_global":27,"./_has":28,"./_hide":29,"./_uid":57}],49:[function(require,module,exports){
3735var def = require('./_object-dp').f;
3736var has = require('./_has');
3737var TAG = require('./_wks')('toStringTag');
3738
3739module.exports = function (it, tag, stat) {
3740 if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
3741};
3742
3743},{"./_has":28,"./_object-dp":38,"./_wks":60}],50:[function(require,module,exports){
3744var shared = require('./_shared')('keys');
3745var uid = require('./_uid');
3746module.exports = function (key) {
3747 return shared[key] || (shared[key] = uid(key));
3748};
3749
3750},{"./_shared":51,"./_uid":57}],51:[function(require,module,exports){
3751var core = require('./_core');
3752var global = require('./_global');
3753var SHARED = '__core-js_shared__';
3754var store = global[SHARED] || (global[SHARED] = {});
3755
3756(module.exports = function (key, value) {
3757 return store[key] || (store[key] = value !== undefined ? value : {});
3758})('versions', []).push({
3759 version: core.version,
3760 mode: require('./_library') ? 'pure' : 'global',
3761 copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
3762});
3763
3764},{"./_core":18,"./_global":27,"./_library":35}],52:[function(require,module,exports){
3765var toInteger = require('./_to-integer');
3766var max = Math.max;
3767var min = Math.min;
3768module.exports = function (index, length) {
3769 index = toInteger(index);
3770 return index < 0 ? max(index + length, 0) : min(index, length);
3771};
3772
3773},{"./_to-integer":53}],53:[function(require,module,exports){
3774// 7.1.4 ToInteger
3775var ceil = Math.ceil;
3776var floor = Math.floor;
3777module.exports = function (it) {
3778 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
3779};
3780
3781},{}],54:[function(require,module,exports){
3782// to indexed object, toObject with fallback for non-array-like ES3 strings
3783var IObject = require('./_iobject');
3784var defined = require('./_defined');
3785module.exports = function (it) {
3786 return IObject(defined(it));
3787};
3788
3789},{"./_defined":20,"./_iobject":32}],55:[function(require,module,exports){
3790// 7.1.15 ToLength
3791var toInteger = require('./_to-integer');
3792var min = Math.min;
3793module.exports = function (it) {
3794 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
3795};
3796
3797},{"./_to-integer":53}],56:[function(require,module,exports){
3798// 7.1.1 ToPrimitive(input [, PreferredType])
3799var isObject = require('./_is-object');
3800// instead of the ES6 spec version, we didn't implement @@toPrimitive case
3801// and the second argument - flag - preferred type is a string
3802module.exports = function (it, S) {
3803 if (!isObject(it)) return it;
3804 var fn, val;
3805 if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
3806 if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
3807 if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
3808 throw TypeError("Can't convert object to primitive value");
3809};
3810
3811},{"./_is-object":34}],57:[function(require,module,exports){
3812var id = 0;
3813var px = Math.random();
3814module.exports = function (key) {
3815 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
3816};
3817
3818},{}],58:[function(require,module,exports){
3819var global = require('./_global');
3820var core = require('./_core');
3821var LIBRARY = require('./_library');
3822var wksExt = require('./_wks-ext');
3823var defineProperty = require('./_object-dp').f;
3824module.exports = function (name) {
3825 var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
3826 if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
3827};
3828
3829},{"./_core":18,"./_global":27,"./_library":35,"./_object-dp":38,"./_wks-ext":59}],59:[function(require,module,exports){
3830exports.f = require('./_wks');
3831
3832},{"./_wks":60}],60:[function(require,module,exports){
3833var store = require('./_shared')('wks');
3834var uid = require('./_uid');
3835var Symbol = require('./_global').Symbol;
3836var USE_SYMBOL = typeof Symbol == 'function';
3837
3838var $exports = module.exports = function (name) {
3839 return store[name] || (store[name] =
3840 USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
3841};
3842
3843$exports.store = store;
3844
3845},{"./_global":27,"./_shared":51,"./_uid":57}],61:[function(require,module,exports){
3846'use strict';
3847// 19.1.3.6 Object.prototype.toString()
3848var classof = require('./_classof');
3849var test = {};
3850test[require('./_wks')('toStringTag')] = 'z';
3851if (test + '' != '[object z]') {
3852 require('./_redefine')(Object.prototype, 'toString', function toString() {
3853 return '[object ' + classof(this) + ']';
3854 }, true);
3855}
3856
3857},{"./_classof":16,"./_redefine":48,"./_wks":60}],62:[function(require,module,exports){
3858'use strict';
3859// ECMAScript 6 symbols shim
3860var global = require('./_global');
3861var has = require('./_has');
3862var DESCRIPTORS = require('./_descriptors');
3863var $export = require('./_export');
3864var redefine = require('./_redefine');
3865var META = require('./_meta').KEY;
3866var $fails = require('./_fails');
3867var shared = require('./_shared');
3868var setToStringTag = require('./_set-to-string-tag');
3869var uid = require('./_uid');
3870var wks = require('./_wks');
3871var wksExt = require('./_wks-ext');
3872var wksDefine = require('./_wks-define');
3873var enumKeys = require('./_enum-keys');
3874var isArray = require('./_is-array');
3875var anObject = require('./_an-object');
3876var isObject = require('./_is-object');
3877var toIObject = require('./_to-iobject');
3878var toPrimitive = require('./_to-primitive');
3879var createDesc = require('./_property-desc');
3880var _create = require('./_object-create');
3881var gOPNExt = require('./_object-gopn-ext');
3882var $GOPD = require('./_object-gopd');
3883var $DP = require('./_object-dp');
3884var $keys = require('./_object-keys');
3885var gOPD = $GOPD.f;
3886var dP = $DP.f;
3887var gOPN = gOPNExt.f;
3888var $Symbol = global.Symbol;
3889var $JSON = global.JSON;
3890var _stringify = $JSON && $JSON.stringify;
3891var PROTOTYPE = 'prototype';
3892var HIDDEN = wks('_hidden');
3893var TO_PRIMITIVE = wks('toPrimitive');
3894var isEnum = {}.propertyIsEnumerable;
3895var SymbolRegistry = shared('symbol-registry');
3896var AllSymbols = shared('symbols');
3897var OPSymbols = shared('op-symbols');
3898var ObjectProto = Object[PROTOTYPE];
3899var USE_NATIVE = typeof $Symbol == 'function';
3900var QObject = global.QObject;
3901// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
3902var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
3903
3904// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
3905var setSymbolDesc = DESCRIPTORS && $fails(function () {
3906 return _create(dP({}, 'a', {
3907 get: function () { return dP(this, 'a', { value: 7 }).a; }
3908 })).a != 7;
3909}) ? function (it, key, D) {
3910 var protoDesc = gOPD(ObjectProto, key);
3911 if (protoDesc) delete ObjectProto[key];
3912 dP(it, key, D);
3913 if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
3914} : dP;
3915
3916var wrap = function (tag) {
3917 var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
3918 sym._k = tag;
3919 return sym;
3920};
3921
3922var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
3923 return typeof it == 'symbol';
3924} : function (it) {
3925 return it instanceof $Symbol;
3926};
3927
3928var $defineProperty = function defineProperty(it, key, D) {
3929 if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
3930 anObject(it);
3931 key = toPrimitive(key, true);
3932 anObject(D);
3933 if (has(AllSymbols, key)) {
3934 if (!D.enumerable) {
3935 if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
3936 it[HIDDEN][key] = true;
3937 } else {
3938 if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
3939 D = _create(D, { enumerable: createDesc(0, false) });
3940 } return setSymbolDesc(it, key, D);
3941 } return dP(it, key, D);
3942};
3943var $defineProperties = function defineProperties(it, P) {
3944 anObject(it);
3945 var keys = enumKeys(P = toIObject(P));
3946 var i = 0;
3947 var l = keys.length;
3948 var key;
3949 while (l > i) $defineProperty(it, key = keys[i++], P[key]);
3950 return it;
3951};
3952var $create = function create(it, P) {
3953 return P === undefined ? _create(it) : $defineProperties(_create(it), P);
3954};
3955var $propertyIsEnumerable = function propertyIsEnumerable(key) {
3956 var E = isEnum.call(this, key = toPrimitive(key, true));
3957 if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
3958 return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
3959};
3960var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
3961 it = toIObject(it);
3962 key = toPrimitive(key, true);
3963 if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
3964 var D = gOPD(it, key);
3965 if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
3966 return D;
3967};
3968var $getOwnPropertyNames = function getOwnPropertyNames(it) {
3969 var names = gOPN(toIObject(it));
3970 var result = [];
3971 var i = 0;
3972 var key;
3973 while (names.length > i) {
3974 if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
3975 } return result;
3976};
3977var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
3978 var IS_OP = it === ObjectProto;
3979 var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
3980 var result = [];
3981 var i = 0;
3982 var key;
3983 while (names.length > i) {
3984 if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
3985 } return result;
3986};
3987
3988// 19.4.1.1 Symbol([description])
3989if (!USE_NATIVE) {
3990 $Symbol = function Symbol() {
3991 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
3992 var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
3993 var $set = function (value) {
3994 if (this === ObjectProto) $set.call(OPSymbols, value);
3995 if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
3996 setSymbolDesc(this, tag, createDesc(1, value));
3997 };
3998 if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
3999 return wrap(tag);
4000 };
4001 redefine($Symbol[PROTOTYPE], 'toString', function toString() {
4002 return this._k;
4003 });
4004
4005 $GOPD.f = $getOwnPropertyDescriptor;
4006 $DP.f = $defineProperty;
4007 require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;
4008 require('./_object-pie').f = $propertyIsEnumerable;
4009 require('./_object-gops').f = $getOwnPropertySymbols;
4010
4011 if (DESCRIPTORS && !require('./_library')) {
4012 redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
4013 }
4014
4015 wksExt.f = function (name) {
4016 return wrap(wks(name));
4017 };
4018}
4019
4020$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
4021
4022for (var es6Symbols = (
4023 // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
4024 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
4025).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
4026
4027for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
4028
4029$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
4030 // 19.4.2.1 Symbol.for(key)
4031 'for': function (key) {
4032 return has(SymbolRegistry, key += '')
4033 ? SymbolRegistry[key]
4034 : SymbolRegistry[key] = $Symbol(key);
4035 },
4036 // 19.4.2.5 Symbol.keyFor(sym)
4037 keyFor: function keyFor(sym) {
4038 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
4039 for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
4040 },
4041 useSetter: function () { setter = true; },
4042 useSimple: function () { setter = false; }
4043});
4044
4045$export($export.S + $export.F * !USE_NATIVE, 'Object', {
4046 // 19.1.2.2 Object.create(O [, Properties])
4047 create: $create,
4048 // 19.1.2.4 Object.defineProperty(O, P, Attributes)
4049 defineProperty: $defineProperty,
4050 // 19.1.2.3 Object.defineProperties(O, Properties)
4051 defineProperties: $defineProperties,
4052 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
4053 getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
4054 // 19.1.2.7 Object.getOwnPropertyNames(O)
4055 getOwnPropertyNames: $getOwnPropertyNames,
4056 // 19.1.2.8 Object.getOwnPropertySymbols(O)
4057 getOwnPropertySymbols: $getOwnPropertySymbols
4058});
4059
4060// 24.3.2 JSON.stringify(value [, replacer [, space]])
4061$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
4062 var S = $Symbol();
4063 // MS Edge converts symbol values to JSON as {}
4064 // WebKit converts symbol values to JSON as null
4065 // V8 throws on boxed symbols
4066 return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
4067})), 'JSON', {
4068 stringify: function stringify(it) {
4069 var args = [it];
4070 var i = 1;
4071 var replacer, $replacer;
4072 while (arguments.length > i) args.push(arguments[i++]);
4073 $replacer = replacer = args[1];
4074 if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
4075 if (!isArray(replacer)) replacer = function (key, value) {
4076 if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
4077 if (!isSymbol(value)) return value;
4078 };
4079 args[1] = replacer;
4080 return _stringify.apply($JSON, args);
4081 }
4082});
4083
4084// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
4085$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
4086// 19.4.3.5 Symbol.prototype[@@toStringTag]
4087setToStringTag($Symbol, 'Symbol');
4088// 20.2.1.9 Math[@@toStringTag]
4089setToStringTag(Math, 'Math', true);
4090// 24.3.3 JSON[@@toStringTag]
4091setToStringTag(global.JSON, 'JSON', true);
4092
4093},{"./_an-object":14,"./_descriptors":21,"./_enum-keys":24,"./_export":25,"./_fails":26,"./_global":27,"./_has":28,"./_hide":29,"./_is-array":33,"./_is-object":34,"./_library":35,"./_meta":36,"./_object-create":37,"./_object-dp":38,"./_object-gopd":40,"./_object-gopn":42,"./_object-gopn-ext":41,"./_object-gops":43,"./_object-keys":45,"./_object-pie":46,"./_property-desc":47,"./_redefine":48,"./_set-to-string-tag":49,"./_shared":51,"./_to-iobject":54,"./_to-primitive":56,"./_uid":57,"./_wks":60,"./_wks-define":58,"./_wks-ext":59}],63:[function(require,module,exports){
4094(function (Buffer){
4095// Copyright Joyent, Inc. and other Node contributors.
4096//
4097// Permission is hereby granted, free of charge, to any person obtaining a
4098// copy of this software and associated documentation files (the
4099// "Software"), to deal in the Software without restriction, including
4100// without limitation the rights to use, copy, modify, merge, publish,
4101// distribute, sublicense, and/or sell copies of the Software, and to permit
4102// persons to whom the Software is furnished to do so, subject to the
4103// following conditions:
4104//
4105// The above copyright notice and this permission notice shall be included
4106// in all copies or substantial portions of the Software.
4107//
4108// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4109// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4110// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
4111// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
4112// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
4113// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
4114// USE OR OTHER DEALINGS IN THE SOFTWARE.
4115
4116// NOTE: These type checking functions intentionally don't use `instanceof`
4117// because it is fragile and can be easily faked with `Object.create()`.
4118
4119function isArray(arg) {
4120 if (Array.isArray) {
4121 return Array.isArray(arg);
4122 }
4123 return objectToString(arg) === '[object Array]';
4124}
4125exports.isArray = isArray;
4126
4127function isBoolean(arg) {
4128 return typeof arg === 'boolean';
4129}
4130exports.isBoolean = isBoolean;
4131
4132function isNull(arg) {
4133 return arg === null;
4134}
4135exports.isNull = isNull;
4136
4137function isNullOrUndefined(arg) {
4138 return arg == null;
4139}
4140exports.isNullOrUndefined = isNullOrUndefined;
4141
4142function isNumber(arg) {
4143 return typeof arg === 'number';
4144}
4145exports.isNumber = isNumber;
4146
4147function isString(arg) {
4148 return typeof arg === 'string';
4149}
4150exports.isString = isString;
4151
4152function isSymbol(arg) {
4153 return typeof arg === 'symbol';
4154}
4155exports.isSymbol = isSymbol;
4156
4157function isUndefined(arg) {
4158 return arg === void 0;
4159}
4160exports.isUndefined = isUndefined;
4161
4162function isRegExp(re) {
4163 return objectToString(re) === '[object RegExp]';
4164}
4165exports.isRegExp = isRegExp;
4166
4167function isObject(arg) {
4168 return typeof arg === 'object' && arg !== null;
4169}
4170exports.isObject = isObject;
4171
4172function isDate(d) {
4173 return objectToString(d) === '[object Date]';
4174}
4175exports.isDate = isDate;
4176
4177function isError(e) {
4178 return (objectToString(e) === '[object Error]' || e instanceof Error);
4179}
4180exports.isError = isError;
4181
4182function isFunction(arg) {
4183 return typeof arg === 'function';
4184}
4185exports.isFunction = isFunction;
4186
4187function isPrimitive(arg) {
4188 return arg === null ||
4189 typeof arg === 'boolean' ||
4190 typeof arg === 'number' ||
4191 typeof arg === 'string' ||
4192 typeof arg === 'symbol' || // ES6 symbol
4193 typeof arg === 'undefined';
4194}
4195exports.isPrimitive = isPrimitive;
4196
4197exports.isBuffer = Buffer.isBuffer;
4198
4199function objectToString(o) {
4200 return Object.prototype.toString.call(o);
4201}
4202
4203}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
4204
4205},{"../../is-buffer/index.js":69}],64:[function(require,module,exports){
4206// Copyright Joyent, Inc. and other Node contributors.
4207//
4208// Permission is hereby granted, free of charge, to any person obtaining a
4209// copy of this software and associated documentation files (the
4210// "Software"), to deal in the Software without restriction, including
4211// without limitation the rights to use, copy, modify, merge, publish,
4212// distribute, sublicense, and/or sell copies of the Software, and to permit
4213// persons to whom the Software is furnished to do so, subject to the
4214// following conditions:
4215//
4216// The above copyright notice and this permission notice shall be included
4217// in all copies or substantial portions of the Software.
4218//
4219// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4220// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4221// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
4222// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
4223// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
4224// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
4225// USE OR OTHER DEALINGS IN THE SOFTWARE.
4226
4227var objectCreate = Object.create || objectCreatePolyfill
4228var objectKeys = Object.keys || objectKeysPolyfill
4229var bind = Function.prototype.bind || functionBindPolyfill
4230
4231function EventEmitter() {
4232 if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
4233 this._events = objectCreate(null);
4234 this._eventsCount = 0;
4235 }
4236
4237 this._maxListeners = this._maxListeners || undefined;
4238}
4239module.exports = EventEmitter;
4240
4241// Backwards-compat with node 0.10.x
4242EventEmitter.EventEmitter = EventEmitter;
4243
4244EventEmitter.prototype._events = undefined;
4245EventEmitter.prototype._maxListeners = undefined;
4246
4247// By default EventEmitters will print a warning if more than 10 listeners are
4248// added to it. This is a useful default which helps finding memory leaks.
4249var defaultMaxListeners = 10;
4250
4251var hasDefineProperty;
4252try {
4253 var o = {};
4254 if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
4255 hasDefineProperty = o.x === 0;
4256} catch (err) { hasDefineProperty = false }
4257if (hasDefineProperty) {
4258 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
4259 enumerable: true,
4260 get: function() {
4261 return defaultMaxListeners;
4262 },
4263 set: function(arg) {
4264 // check whether the input is a positive number (whose value is zero or
4265 // greater and not a NaN).
4266 if (typeof arg !== 'number' || arg < 0 || arg !== arg)
4267 throw new TypeError('"defaultMaxListeners" must be a positive number');
4268 defaultMaxListeners = arg;
4269 }
4270 });
4271} else {
4272 EventEmitter.defaultMaxListeners = defaultMaxListeners;
4273}
4274
4275// Obviously not all Emitters should be limited to 10. This function allows
4276// that to be increased. Set to zero for unlimited.
4277EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
4278 if (typeof n !== 'number' || n < 0 || isNaN(n))
4279 throw new TypeError('"n" argument must be a positive number');
4280 this._maxListeners = n;
4281 return this;
4282};
4283
4284function $getMaxListeners(that) {
4285 if (that._maxListeners === undefined)
4286 return EventEmitter.defaultMaxListeners;
4287 return that._maxListeners;
4288}
4289
4290EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
4291 return $getMaxListeners(this);
4292};
4293
4294// These standalone emit* functions are used to optimize calling of event
4295// handlers for fast cases because emit() itself often has a variable number of
4296// arguments and can be deoptimized because of that. These functions always have
4297// the same number of arguments and thus do not get deoptimized, so the code
4298// inside them can execute faster.
4299function emitNone(handler, isFn, self) {
4300 if (isFn)
4301 handler.call(self);
4302 else {
4303 var len = handler.length;
4304 var listeners = arrayClone(handler, len);
4305 for (var i = 0; i < len; ++i)
4306 listeners[i].call(self);
4307 }
4308}
4309function emitOne(handler, isFn, self, arg1) {
4310 if (isFn)
4311 handler.call(self, arg1);
4312 else {
4313 var len = handler.length;
4314 var listeners = arrayClone(handler, len);
4315 for (var i = 0; i < len; ++i)
4316 listeners[i].call(self, arg1);
4317 }
4318}
4319function emitTwo(handler, isFn, self, arg1, arg2) {
4320 if (isFn)
4321 handler.call(self, arg1, arg2);
4322 else {
4323 var len = handler.length;
4324 var listeners = arrayClone(handler, len);
4325 for (var i = 0; i < len; ++i)
4326 listeners[i].call(self, arg1, arg2);
4327 }
4328}
4329function emitThree(handler, isFn, self, arg1, arg2, arg3) {
4330 if (isFn)
4331 handler.call(self, arg1, arg2, arg3);
4332 else {
4333 var len = handler.length;
4334 var listeners = arrayClone(handler, len);
4335 for (var i = 0; i < len; ++i)
4336 listeners[i].call(self, arg1, arg2, arg3);
4337 }
4338}
4339
4340function emitMany(handler, isFn, self, args) {
4341 if (isFn)
4342 handler.apply(self, args);
4343 else {
4344 var len = handler.length;
4345 var listeners = arrayClone(handler, len);
4346 for (var i = 0; i < len; ++i)
4347 listeners[i].apply(self, args);
4348 }
4349}
4350
4351EventEmitter.prototype.emit = function emit(type) {
4352 var er, handler, len, args, i, events;
4353 var doError = (type === 'error');
4354
4355 events = this._events;
4356 if (events)
4357 doError = (doError && events.error == null);
4358 else if (!doError)
4359 return false;
4360
4361 // If there is no 'error' event listener then throw.
4362 if (doError) {
4363 if (arguments.length > 1)
4364 er = arguments[1];
4365 if (er instanceof Error) {
4366 throw er; // Unhandled 'error' event
4367 } else {
4368 // At least give some kind of context to the user
4369 var err = new Error('Unhandled "error" event. (' + er + ')');
4370 err.context = er;
4371 throw err;
4372 }
4373 return false;
4374 }
4375
4376 handler = events[type];
4377
4378 if (!handler)
4379 return false;
4380
4381 var isFn = typeof handler === 'function';
4382 len = arguments.length;
4383 switch (len) {
4384 // fast cases
4385 case 1:
4386 emitNone(handler, isFn, this);
4387 break;
4388 case 2:
4389 emitOne(handler, isFn, this, arguments[1]);
4390 break;
4391 case 3:
4392 emitTwo(handler, isFn, this, arguments[1], arguments[2]);
4393 break;
4394 case 4:
4395 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
4396 break;
4397 // slower
4398 default:
4399 args = new Array(len - 1);
4400 for (i = 1; i < len; i++)
4401 args[i - 1] = arguments[i];
4402 emitMany(handler, isFn, this, args);
4403 }
4404
4405 return true;
4406};
4407
4408function _addListener(target, type, listener, prepend) {
4409 var m;
4410 var events;
4411 var existing;
4412
4413 if (typeof listener !== 'function')
4414 throw new TypeError('"listener" argument must be a function');
4415
4416 events = target._events;
4417 if (!events) {
4418 events = target._events = objectCreate(null);
4419 target._eventsCount = 0;
4420 } else {
4421 // To avoid recursion in the case that type === "newListener"! Before
4422 // adding it to the listeners, first emit "newListener".
4423 if (events.newListener) {
4424 target.emit('newListener', type,
4425 listener.listener ? listener.listener : listener);
4426
4427 // Re-assign `events` because a newListener handler could have caused the
4428 // this._events to be assigned to a new object
4429 events = target._events;
4430 }
4431 existing = events[type];
4432 }
4433
4434 if (!existing) {
4435 // Optimize the case of one listener. Don't need the extra array object.
4436 existing = events[type] = listener;
4437 ++target._eventsCount;
4438 } else {
4439 if (typeof existing === 'function') {
4440 // Adding the second element, need to change to array.
4441 existing = events[type] =
4442 prepend ? [listener, existing] : [existing, listener];
4443 } else {
4444 // If we've already got an array, just append.
4445 if (prepend) {
4446 existing.unshift(listener);
4447 } else {
4448 existing.push(listener);
4449 }
4450 }
4451
4452 // Check for listener leak
4453 if (!existing.warned) {
4454 m = $getMaxListeners(target);
4455 if (m && m > 0 && existing.length > m) {
4456 existing.warned = true;
4457 var w = new Error('Possible EventEmitter memory leak detected. ' +
4458 existing.length + ' "' + String(type) + '" listeners ' +
4459 'added. Use emitter.setMaxListeners() to ' +
4460 'increase limit.');
4461 w.name = 'MaxListenersExceededWarning';
4462 w.emitter = target;
4463 w.type = type;
4464 w.count = existing.length;
4465 if (typeof console === 'object' && console.warn) {
4466 console.warn('%s: %s', w.name, w.message);
4467 }
4468 }
4469 }
4470 }
4471
4472 return target;
4473}
4474
4475EventEmitter.prototype.addListener = function addListener(type, listener) {
4476 return _addListener(this, type, listener, false);
4477};
4478
4479EventEmitter.prototype.on = EventEmitter.prototype.addListener;
4480
4481EventEmitter.prototype.prependListener =
4482 function prependListener(type, listener) {
4483 return _addListener(this, type, listener, true);
4484 };
4485
4486function onceWrapper() {
4487 if (!this.fired) {
4488 this.target.removeListener(this.type, this.wrapFn);
4489 this.fired = true;
4490 switch (arguments.length) {
4491 case 0:
4492 return this.listener.call(this.target);
4493 case 1:
4494 return this.listener.call(this.target, arguments[0]);
4495 case 2:
4496 return this.listener.call(this.target, arguments[0], arguments[1]);
4497 case 3:
4498 return this.listener.call(this.target, arguments[0], arguments[1],
4499 arguments[2]);
4500 default:
4501 var args = new Array(arguments.length);
4502 for (var i = 0; i < args.length; ++i)
4503 args[i] = arguments[i];
4504 this.listener.apply(this.target, args);
4505 }
4506 }
4507}
4508
4509function _onceWrap(target, type, listener) {
4510 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
4511 var wrapped = bind.call(onceWrapper, state);
4512 wrapped.listener = listener;
4513 state.wrapFn = wrapped;
4514 return wrapped;
4515}
4516
4517EventEmitter.prototype.once = function once(type, listener) {
4518 if (typeof listener !== 'function')
4519 throw new TypeError('"listener" argument must be a function');
4520 this.on(type, _onceWrap(this, type, listener));
4521 return this;
4522};
4523
4524EventEmitter.prototype.prependOnceListener =
4525 function prependOnceListener(type, listener) {
4526 if (typeof listener !== 'function')
4527 throw new TypeError('"listener" argument must be a function');
4528 this.prependListener(type, _onceWrap(this, type, listener));
4529 return this;
4530 };
4531
4532// Emits a 'removeListener' event if and only if the listener was removed.
4533EventEmitter.prototype.removeListener =
4534 function removeListener(type, listener) {
4535 var list, events, position, i, originalListener;
4536
4537 if (typeof listener !== 'function')
4538 throw new TypeError('"listener" argument must be a function');
4539
4540 events = this._events;
4541 if (!events)
4542 return this;
4543
4544 list = events[type];
4545 if (!list)
4546 return this;
4547
4548 if (list === listener || list.listener === listener) {
4549 if (--this._eventsCount === 0)
4550 this._events = objectCreate(null);
4551 else {
4552 delete events[type];
4553 if (events.removeListener)
4554 this.emit('removeListener', type, list.listener || listener);
4555 }
4556 } else if (typeof list !== 'function') {
4557 position = -1;
4558
4559 for (i = list.length - 1; i >= 0; i--) {
4560 if (list[i] === listener || list[i].listener === listener) {
4561 originalListener = list[i].listener;
4562 position = i;
4563 break;
4564 }
4565 }
4566
4567 if (position < 0)
4568 return this;
4569
4570 if (position === 0)
4571 list.shift();
4572 else
4573 spliceOne(list, position);
4574
4575 if (list.length === 1)
4576 events[type] = list[0];
4577
4578 if (events.removeListener)
4579 this.emit('removeListener', type, originalListener || listener);
4580 }
4581
4582 return this;
4583 };
4584
4585EventEmitter.prototype.removeAllListeners =
4586 function removeAllListeners(type) {
4587 var listeners, events, i;
4588
4589 events = this._events;
4590 if (!events)
4591 return this;
4592
4593 // not listening for removeListener, no need to emit
4594 if (!events.removeListener) {
4595 if (arguments.length === 0) {
4596 this._events = objectCreate(null);
4597 this._eventsCount = 0;
4598 } else if (events[type]) {
4599 if (--this._eventsCount === 0)
4600 this._events = objectCreate(null);
4601 else
4602 delete events[type];
4603 }
4604 return this;
4605 }
4606
4607 // emit removeListener for all listeners on all events
4608 if (arguments.length === 0) {
4609 var keys = objectKeys(events);
4610 var key;
4611 for (i = 0; i < keys.length; ++i) {
4612 key = keys[i];
4613 if (key === 'removeListener') continue;
4614 this.removeAllListeners(key);
4615 }
4616 this.removeAllListeners('removeListener');
4617 this._events = objectCreate(null);
4618 this._eventsCount = 0;
4619 return this;
4620 }
4621
4622 listeners = events[type];
4623
4624 if (typeof listeners === 'function') {
4625 this.removeListener(type, listeners);
4626 } else if (listeners) {
4627 // LIFO order
4628 for (i = listeners.length - 1; i >= 0; i--) {
4629 this.removeListener(type, listeners[i]);
4630 }
4631 }
4632
4633 return this;
4634 };
4635
4636function _listeners(target, type, unwrap) {
4637 var events = target._events;
4638
4639 if (!events)
4640 return [];
4641
4642 var evlistener = events[type];
4643 if (!evlistener)
4644 return [];
4645
4646 if (typeof evlistener === 'function')
4647 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
4648
4649 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
4650}
4651
4652EventEmitter.prototype.listeners = function listeners(type) {
4653 return _listeners(this, type, true);
4654};
4655
4656EventEmitter.prototype.rawListeners = function rawListeners(type) {
4657 return _listeners(this, type, false);
4658};
4659
4660EventEmitter.listenerCount = function(emitter, type) {
4661 if (typeof emitter.listenerCount === 'function') {
4662 return emitter.listenerCount(type);
4663 } else {
4664 return listenerCount.call(emitter, type);
4665 }
4666};
4667
4668EventEmitter.prototype.listenerCount = listenerCount;
4669function listenerCount(type) {
4670 var events = this._events;
4671
4672 if (events) {
4673 var evlistener = events[type];
4674
4675 if (typeof evlistener === 'function') {
4676 return 1;
4677 } else if (evlistener) {
4678 return evlistener.length;
4679 }
4680 }
4681
4682 return 0;
4683}
4684
4685EventEmitter.prototype.eventNames = function eventNames() {
4686 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
4687};
4688
4689// About 1.5x faster than the two-arg version of Array#splice().
4690function spliceOne(list, index) {
4691 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
4692 list[i] = list[k];
4693 list.pop();
4694}
4695
4696function arrayClone(arr, n) {
4697 var copy = new Array(n);
4698 for (var i = 0; i < n; ++i)
4699 copy[i] = arr[i];
4700 return copy;
4701}
4702
4703function unwrapListeners(arr) {
4704 var ret = new Array(arr.length);
4705 for (var i = 0; i < ret.length; ++i) {
4706 ret[i] = arr[i].listener || arr[i];
4707 }
4708 return ret;
4709}
4710
4711function objectCreatePolyfill(proto) {
4712 var F = function() {};
4713 F.prototype = proto;
4714 return new F;
4715}
4716function objectKeysPolyfill(obj) {
4717 var keys = [];
4718 for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
4719 keys.push(k);
4720 }
4721 return k;
4722}
4723function functionBindPolyfill(context) {
4724 var fn = this;
4725 return function () {
4726 return fn.apply(context, arguments);
4727 };
4728}
4729
4730},{}],65:[function(require,module,exports){
4731function format(fmt) {
4732 var re = /(%?)(%([jds]))/g
4733 , args = Array.prototype.slice.call(arguments, 1);
4734 if(args.length) {
4735 fmt = fmt.replace(re, function(match, escaped, ptn, flag) {
4736 var arg = args.shift();
4737 switch(flag) {
4738 case 's':
4739 arg = '' + arg;
4740 break;
4741 case 'd':
4742 arg = Number(arg);
4743 break;
4744 case 'j':
4745 arg = JSON.stringify(arg);
4746 break;
4747 }
4748 if(!escaped) {
4749 return arg;
4750 }
4751 args.unshift(arg);
4752 return match;
4753 })
4754 }
4755
4756 // arguments remain after formatting
4757 if(args.length) {
4758 fmt += ' ' + args.join(' ');
4759 }
4760
4761 // update escaped %% values
4762 fmt = fmt.replace(/%{2,2}/g, '%');
4763
4764 return '' + fmt;
4765}
4766
4767module.exports = format;
4768
4769},{}],66:[function(require,module,exports){
4770var http = require('http')
4771var url = require('url')
4772
4773var https = module.exports
4774
4775for (var key in http) {
4776 if (http.hasOwnProperty(key)) https[key] = http[key]
4777}
4778
4779https.request = function (params, cb) {
4780 params = validateParams(params)
4781 return http.request.call(this, params, cb)
4782}
4783
4784https.get = function (params, cb) {
4785 params = validateParams(params)
4786 return http.get.call(this, params, cb)
4787}
4788
4789function validateParams (params) {
4790 if (typeof params === 'string') {
4791 params = url.parse(params)
4792 }
4793 if (!params.protocol) {
4794 params.protocol = 'https:'
4795 }
4796 if (params.protocol !== 'https:') {
4797 throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
4798 }
4799 return params
4800}
4801
4802},{"http":139,"url":148}],67:[function(require,module,exports){
4803exports.read = function (buffer, offset, isLE, mLen, nBytes) {
4804 var e, m
4805 var eLen = (nBytes * 8) - mLen - 1
4806 var eMax = (1 << eLen) - 1
4807 var eBias = eMax >> 1
4808 var nBits = -7
4809 var i = isLE ? (nBytes - 1) : 0
4810 var d = isLE ? -1 : 1
4811 var s = buffer[offset + i]
4812
4813 i += d
4814
4815 e = s & ((1 << (-nBits)) - 1)
4816 s >>= (-nBits)
4817 nBits += eLen
4818 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
4819
4820 m = e & ((1 << (-nBits)) - 1)
4821 e >>= (-nBits)
4822 nBits += mLen
4823 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
4824
4825 if (e === 0) {
4826 e = 1 - eBias
4827 } else if (e === eMax) {
4828 return m ? NaN : ((s ? -1 : 1) * Infinity)
4829 } else {
4830 m = m + Math.pow(2, mLen)
4831 e = e - eBias
4832 }
4833 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
4834}
4835
4836exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
4837 var e, m, c
4838 var eLen = (nBytes * 8) - mLen - 1
4839 var eMax = (1 << eLen) - 1
4840 var eBias = eMax >> 1
4841 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
4842 var i = isLE ? 0 : (nBytes - 1)
4843 var d = isLE ? 1 : -1
4844 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
4845
4846 value = Math.abs(value)
4847
4848 if (isNaN(value) || value === Infinity) {
4849 m = isNaN(value) ? 1 : 0
4850 e = eMax
4851 } else {
4852 e = Math.floor(Math.log(value) / Math.LN2)
4853 if (value * (c = Math.pow(2, -e)) < 1) {
4854 e--
4855 c *= 2
4856 }
4857 if (e + eBias >= 1) {
4858 value += rt / c
4859 } else {
4860 value += rt * Math.pow(2, 1 - eBias)
4861 }
4862 if (value * c >= 2) {
4863 e++
4864 c /= 2
4865 }
4866
4867 if (e + eBias >= eMax) {
4868 m = 0
4869 e = eMax
4870 } else if (e + eBias >= 1) {
4871 m = ((value * c) - 1) * Math.pow(2, mLen)
4872 e = e + eBias
4873 } else {
4874 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
4875 e = 0
4876 }
4877 }
4878
4879 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
4880
4881 e = (e << mLen) | m
4882 eLen += mLen
4883 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
4884
4885 buffer[offset + i - d] |= s * 128
4886}
4887
4888},{}],68:[function(require,module,exports){
4889if (typeof Object.create === 'function') {
4890 // implementation from standard node.js 'util' module
4891 module.exports = function inherits(ctor, superCtor) {
4892 ctor.super_ = superCtor
4893 ctor.prototype = Object.create(superCtor.prototype, {
4894 constructor: {
4895 value: ctor,
4896 enumerable: false,
4897 writable: true,
4898 configurable: true
4899 }
4900 });
4901 };
4902} else {
4903 // old school shim for old browsers
4904 module.exports = function inherits(ctor, superCtor) {
4905 ctor.super_ = superCtor
4906 var TempCtor = function () {}
4907 TempCtor.prototype = superCtor.prototype
4908 ctor.prototype = new TempCtor()
4909 ctor.prototype.constructor = ctor
4910 }
4911}
4912
4913},{}],69:[function(require,module,exports){
4914/*!
4915 * Determine if an object is a Buffer
4916 *
4917 * @author Feross Aboukhadijeh <https://feross.org>
4918 * @license MIT
4919 */
4920
4921// The _isBuffer check is for Safari 5-7 support, because it's missing
4922// Object.prototype.constructor. Remove this eventually
4923module.exports = function (obj) {
4924 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
4925}
4926
4927function isBuffer (obj) {
4928 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
4929}
4930
4931// For Node v0.10 support. Remove this eventually.
4932function isSlowBuffer (obj) {
4933 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
4934}
4935
4936},{}],70:[function(require,module,exports){
4937var toString = {}.toString;
4938
4939module.exports = Array.isArray || function (arr) {
4940 return toString.call(arr) == '[object Array]';
4941};
4942
4943},{}],71:[function(require,module,exports){
4944'use strict';
4945
4946
4947var yaml = require('./lib/js-yaml.js');
4948
4949
4950module.exports = yaml;
4951
4952},{"./lib/js-yaml.js":72}],72:[function(require,module,exports){
4953'use strict';
4954
4955
4956var loader = require('./js-yaml/loader');
4957var dumper = require('./js-yaml/dumper');
4958
4959
4960function deprecated(name) {
4961 return function () {
4962 throw new Error('Function ' + name + ' is deprecated and cannot be used.');
4963 };
4964}
4965
4966
4967module.exports.Type = require('./js-yaml/type');
4968module.exports.Schema = require('./js-yaml/schema');
4969module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
4970module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
4971module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
4972module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
4973module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
4974module.exports.load = loader.load;
4975module.exports.loadAll = loader.loadAll;
4976module.exports.safeLoad = loader.safeLoad;
4977module.exports.safeLoadAll = loader.safeLoadAll;
4978module.exports.dump = dumper.dump;
4979module.exports.safeDump = dumper.safeDump;
4980module.exports.YAMLException = require('./js-yaml/exception');
4981
4982// Deprecated schema names from JS-YAML 2.0.x
4983module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
4984module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
4985module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
4986
4987// Deprecated functions from JS-YAML 1.x.x
4988module.exports.scan = deprecated('scan');
4989module.exports.parse = deprecated('parse');
4990module.exports.compose = deprecated('compose');
4991module.exports.addConstructor = deprecated('addConstructor');
4992
4993},{"./js-yaml/dumper":74,"./js-yaml/exception":75,"./js-yaml/loader":76,"./js-yaml/schema":78,"./js-yaml/schema/core":79,"./js-yaml/schema/default_full":80,"./js-yaml/schema/default_safe":81,"./js-yaml/schema/failsafe":82,"./js-yaml/schema/json":83,"./js-yaml/type":84}],73:[function(require,module,exports){
4994'use strict';
4995
4996
4997function isNothing(subject) {
4998 return (typeof subject === 'undefined') || (subject === null);
4999}
5000
5001
5002function isObject(subject) {
5003 return (typeof subject === 'object') && (subject !== null);
5004}
5005
5006
5007function toArray(sequence) {
5008 if (Array.isArray(sequence)) return sequence;
5009 else if (isNothing(sequence)) return [];
5010
5011 return [ sequence ];
5012}
5013
5014
5015function extend(target, source) {
5016 var index, length, key, sourceKeys;
5017
5018 if (source) {
5019 sourceKeys = Object.keys(source);
5020
5021 for (index = 0, length = sourceKeys.length; index < length; index += 1) {
5022 key = sourceKeys[index];
5023 target[key] = source[key];
5024 }
5025 }
5026
5027 return target;
5028}
5029
5030
5031function repeat(string, count) {
5032 var result = '', cycle;
5033
5034 for (cycle = 0; cycle < count; cycle += 1) {
5035 result += string;
5036 }
5037
5038 return result;
5039}
5040
5041
5042function isNegativeZero(number) {
5043 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
5044}
5045
5046
5047module.exports.isNothing = isNothing;
5048module.exports.isObject = isObject;
5049module.exports.toArray = toArray;
5050module.exports.repeat = repeat;
5051module.exports.isNegativeZero = isNegativeZero;
5052module.exports.extend = extend;
5053
5054},{}],74:[function(require,module,exports){
5055'use strict';
5056
5057/*eslint-disable no-use-before-define*/
5058
5059var common = require('./common');
5060var YAMLException = require('./exception');
5061var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
5062var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
5063
5064var _toString = Object.prototype.toString;
5065var _hasOwnProperty = Object.prototype.hasOwnProperty;
5066
5067var CHAR_TAB = 0x09; /* Tab */
5068var CHAR_LINE_FEED = 0x0A; /* LF */
5069var CHAR_SPACE = 0x20; /* Space */
5070var CHAR_EXCLAMATION = 0x21; /* ! */
5071var CHAR_DOUBLE_QUOTE = 0x22; /* " */
5072var CHAR_SHARP = 0x23; /* # */
5073var CHAR_PERCENT = 0x25; /* % */
5074var CHAR_AMPERSAND = 0x26; /* & */
5075var CHAR_SINGLE_QUOTE = 0x27; /* ' */
5076var CHAR_ASTERISK = 0x2A; /* * */
5077var CHAR_COMMA = 0x2C; /* , */
5078var CHAR_MINUS = 0x2D; /* - */
5079var CHAR_COLON = 0x3A; /* : */
5080var CHAR_GREATER_THAN = 0x3E; /* > */
5081var CHAR_QUESTION = 0x3F; /* ? */
5082var CHAR_COMMERCIAL_AT = 0x40; /* @ */
5083var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
5084var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
5085var CHAR_GRAVE_ACCENT = 0x60; /* ` */
5086var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
5087var CHAR_VERTICAL_LINE = 0x7C; /* | */
5088var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
5089
5090var ESCAPE_SEQUENCES = {};
5091
5092ESCAPE_SEQUENCES[0x00] = '\\0';
5093ESCAPE_SEQUENCES[0x07] = '\\a';
5094ESCAPE_SEQUENCES[0x08] = '\\b';
5095ESCAPE_SEQUENCES[0x09] = '\\t';
5096ESCAPE_SEQUENCES[0x0A] = '\\n';
5097ESCAPE_SEQUENCES[0x0B] = '\\v';
5098ESCAPE_SEQUENCES[0x0C] = '\\f';
5099ESCAPE_SEQUENCES[0x0D] = '\\r';
5100ESCAPE_SEQUENCES[0x1B] = '\\e';
5101ESCAPE_SEQUENCES[0x22] = '\\"';
5102ESCAPE_SEQUENCES[0x5C] = '\\\\';
5103ESCAPE_SEQUENCES[0x85] = '\\N';
5104ESCAPE_SEQUENCES[0xA0] = '\\_';
5105ESCAPE_SEQUENCES[0x2028] = '\\L';
5106ESCAPE_SEQUENCES[0x2029] = '\\P';
5107
5108var DEPRECATED_BOOLEANS_SYNTAX = [
5109 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
5110 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
5111];
5112
5113function compileStyleMap(schema, map) {
5114 var result, keys, index, length, tag, style, type;
5115
5116 if (map === null) return {};
5117
5118 result = {};
5119 keys = Object.keys(map);
5120
5121 for (index = 0, length = keys.length; index < length; index += 1) {
5122 tag = keys[index];
5123 style = String(map[tag]);
5124
5125 if (tag.slice(0, 2) === '!!') {
5126 tag = 'tag:yaml.org,2002:' + tag.slice(2);
5127 }
5128 type = schema.compiledTypeMap['fallback'][tag];
5129
5130 if (type && _hasOwnProperty.call(type.styleAliases, style)) {
5131 style = type.styleAliases[style];
5132 }
5133
5134 result[tag] = style;
5135 }
5136
5137 return result;
5138}
5139
5140function encodeHex(character) {
5141 var string, handle, length;
5142
5143 string = character.toString(16).toUpperCase();
5144
5145 if (character <= 0xFF) {
5146 handle = 'x';
5147 length = 2;
5148 } else if (character <= 0xFFFF) {
5149 handle = 'u';
5150 length = 4;
5151 } else if (character <= 0xFFFFFFFF) {
5152 handle = 'U';
5153 length = 8;
5154 } else {
5155 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
5156 }
5157
5158 return '\\' + handle + common.repeat('0', length - string.length) + string;
5159}
5160
5161function State(options) {
5162 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
5163 this.indent = Math.max(1, (options['indent'] || 2));
5164 this.noArrayIndent = options['noArrayIndent'] || false;
5165 this.skipInvalid = options['skipInvalid'] || false;
5166 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
5167 this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
5168 this.sortKeys = options['sortKeys'] || false;
5169 this.lineWidth = options['lineWidth'] || 80;
5170 this.noRefs = options['noRefs'] || false;
5171 this.noCompatMode = options['noCompatMode'] || false;
5172 this.condenseFlow = options['condenseFlow'] || false;
5173
5174 this.implicitTypes = this.schema.compiledImplicit;
5175 this.explicitTypes = this.schema.compiledExplicit;
5176
5177 this.tag = null;
5178 this.result = '';
5179
5180 this.duplicates = [];
5181 this.usedDuplicates = null;
5182}
5183
5184// Indents every line in a string. Empty lines (\n only) are not indented.
5185function indentString(string, spaces) {
5186 var ind = common.repeat(' ', spaces),
5187 position = 0,
5188 next = -1,
5189 result = '',
5190 line,
5191 length = string.length;
5192
5193 while (position < length) {
5194 next = string.indexOf('\n', position);
5195 if (next === -1) {
5196 line = string.slice(position);
5197 position = length;
5198 } else {
5199 line = string.slice(position, next + 1);
5200 position = next + 1;
5201 }
5202
5203 if (line.length && line !== '\n') result += ind;
5204
5205 result += line;
5206 }
5207
5208 return result;
5209}
5210
5211function generateNextLine(state, level) {
5212 return '\n' + common.repeat(' ', state.indent * level);
5213}
5214
5215function testImplicitResolving(state, str) {
5216 var index, length, type;
5217
5218 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
5219 type = state.implicitTypes[index];
5220
5221 if (type.resolve(str)) {
5222 return true;
5223 }
5224 }
5225
5226 return false;
5227}
5228
5229// [33] s-white ::= s-space | s-tab
5230function isWhitespace(c) {
5231 return c === CHAR_SPACE || c === CHAR_TAB;
5232}
5233
5234// Returns true if the character can be printed without escaping.
5235// From YAML 1.2: "any allowed characters known to be non-printable
5236// should also be escaped. [However,] This isn’t mandatory"
5237// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
5238function isPrintable(c) {
5239 return (0x00020 <= c && c <= 0x00007E)
5240 || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
5241 || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
5242 || (0x10000 <= c && c <= 0x10FFFF);
5243}
5244
5245// Simplified test for values allowed after the first character in plain style.
5246function isPlainSafe(c) {
5247 // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
5248 // where nb-char ::= c-printable - b-char - c-byte-order-mark.
5249 return isPrintable(c) && c !== 0xFEFF
5250 // - c-flow-indicator
5251 && c !== CHAR_COMMA
5252 && c !== CHAR_LEFT_SQUARE_BRACKET
5253 && c !== CHAR_RIGHT_SQUARE_BRACKET
5254 && c !== CHAR_LEFT_CURLY_BRACKET
5255 && c !== CHAR_RIGHT_CURLY_BRACKET
5256 // - ":" - "#"
5257 && c !== CHAR_COLON
5258 && c !== CHAR_SHARP;
5259}
5260
5261// Simplified test for values allowed as the first character in plain style.
5262function isPlainSafeFirst(c) {
5263 // Uses a subset of ns-char - c-indicator
5264 // where ns-char = nb-char - s-white.
5265 return isPrintable(c) && c !== 0xFEFF
5266 && !isWhitespace(c) // - s-white
5267 // - (c-indicator ::=
5268 // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
5269 && c !== CHAR_MINUS
5270 && c !== CHAR_QUESTION
5271 && c !== CHAR_COLON
5272 && c !== CHAR_COMMA
5273 && c !== CHAR_LEFT_SQUARE_BRACKET
5274 && c !== CHAR_RIGHT_SQUARE_BRACKET
5275 && c !== CHAR_LEFT_CURLY_BRACKET
5276 && c !== CHAR_RIGHT_CURLY_BRACKET
5277 // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
5278 && c !== CHAR_SHARP
5279 && c !== CHAR_AMPERSAND
5280 && c !== CHAR_ASTERISK
5281 && c !== CHAR_EXCLAMATION
5282 && c !== CHAR_VERTICAL_LINE
5283 && c !== CHAR_GREATER_THAN
5284 && c !== CHAR_SINGLE_QUOTE
5285 && c !== CHAR_DOUBLE_QUOTE
5286 // | “%” | “@” | “`”)
5287 && c !== CHAR_PERCENT
5288 && c !== CHAR_COMMERCIAL_AT
5289 && c !== CHAR_GRAVE_ACCENT;
5290}
5291
5292// Determines whether block indentation indicator is required.
5293function needIndentIndicator(string) {
5294 var leadingSpaceRe = /^\n* /;
5295 return leadingSpaceRe.test(string);
5296}
5297
5298var STYLE_PLAIN = 1,
5299 STYLE_SINGLE = 2,
5300 STYLE_LITERAL = 3,
5301 STYLE_FOLDED = 4,
5302 STYLE_DOUBLE = 5;
5303
5304// Determines which scalar styles are possible and returns the preferred style.
5305// lineWidth = -1 => no limit.
5306// Pre-conditions: str.length > 0.
5307// Post-conditions:
5308// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
5309// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
5310// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
5311function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
5312 var i;
5313 var char;
5314 var hasLineBreak = false;
5315 var hasFoldableLine = false; // only checked if shouldTrackWidth
5316 var shouldTrackWidth = lineWidth !== -1;
5317 var previousLineBreak = -1; // count the first line correctly
5318 var plain = isPlainSafeFirst(string.charCodeAt(0))
5319 && !isWhitespace(string.charCodeAt(string.length - 1));
5320
5321 if (singleLineOnly) {
5322 // Case: no block styles.
5323 // Check for disallowed characters to rule out plain and single.
5324 for (i = 0; i < string.length; i++) {
5325 char = string.charCodeAt(i);
5326 if (!isPrintable(char)) {
5327 return STYLE_DOUBLE;
5328 }
5329 plain = plain && isPlainSafe(char);
5330 }
5331 } else {
5332 // Case: block styles permitted.
5333 for (i = 0; i < string.length; i++) {
5334 char = string.charCodeAt(i);
5335 if (char === CHAR_LINE_FEED) {
5336 hasLineBreak = true;
5337 // Check if any line can be folded.
5338 if (shouldTrackWidth) {
5339 hasFoldableLine = hasFoldableLine ||
5340 // Foldable line = too long, and not more-indented.
5341 (i - previousLineBreak - 1 > lineWidth &&
5342 string[previousLineBreak + 1] !== ' ');
5343 previousLineBreak = i;
5344 }
5345 } else if (!isPrintable(char)) {
5346 return STYLE_DOUBLE;
5347 }
5348 plain = plain && isPlainSafe(char);
5349 }
5350 // in case the end is missing a \n
5351 hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
5352 (i - previousLineBreak - 1 > lineWidth &&
5353 string[previousLineBreak + 1] !== ' '));
5354 }
5355 // Although every style can represent \n without escaping, prefer block styles
5356 // for multiline, since they're more readable and they don't add empty lines.
5357 // Also prefer folding a super-long line.
5358 if (!hasLineBreak && !hasFoldableLine) {
5359 // Strings interpretable as another type have to be quoted;
5360 // e.g. the string 'true' vs. the boolean true.
5361 return plain && !testAmbiguousType(string)
5362 ? STYLE_PLAIN : STYLE_SINGLE;
5363 }
5364 // Edge case: block indentation indicator can only have one digit.
5365 if (indentPerLevel > 9 && needIndentIndicator(string)) {
5366 return STYLE_DOUBLE;
5367 }
5368 // At this point we know block styles are valid.
5369 // Prefer literal style unless we want to fold.
5370 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
5371}
5372
5373// Note: line breaking/folding is implemented for only the folded style.
5374// NB. We drop the last trailing newline (if any) of a returned block scalar
5375// since the dumper adds its own newline. This always works:
5376// • No ending newline => unaffected; already using strip "-" chomping.
5377// • Ending newline => removed then restored.
5378// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
5379function writeScalar(state, string, level, iskey) {
5380 state.dump = (function () {
5381 if (string.length === 0) {
5382 return "''";
5383 }
5384 if (!state.noCompatMode &&
5385 DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
5386 return "'" + string + "'";
5387 }
5388
5389 var indent = state.indent * Math.max(1, level); // no 0-indent scalars
5390 // As indentation gets deeper, let the width decrease monotonically
5391 // to the lower bound min(state.lineWidth, 40).
5392 // Note that this implies
5393 // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
5394 // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
5395 // This behaves better than a constant minimum width which disallows narrower options,
5396 // or an indent threshold which causes the width to suddenly increase.
5397 var lineWidth = state.lineWidth === -1
5398 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
5399
5400 // Without knowing if keys are implicit/explicit, assume implicit for safety.
5401 var singleLineOnly = iskey
5402 // No block styles in flow mode.
5403 || (state.flowLevel > -1 && level >= state.flowLevel);
5404 function testAmbiguity(string) {
5405 return testImplicitResolving(state, string);
5406 }
5407
5408 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
5409 case STYLE_PLAIN:
5410 return string;
5411 case STYLE_SINGLE:
5412 return "'" + string.replace(/'/g, "''") + "'";
5413 case STYLE_LITERAL:
5414 return '|' + blockHeader(string, state.indent)
5415 + dropEndingNewline(indentString(string, indent));
5416 case STYLE_FOLDED:
5417 return '>' + blockHeader(string, state.indent)
5418 + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
5419 case STYLE_DOUBLE:
5420 return '"' + escapeString(string, lineWidth) + '"';
5421 default:
5422 throw new YAMLException('impossible error: invalid scalar style');
5423 }
5424 }());
5425}
5426
5427// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
5428function blockHeader(string, indentPerLevel) {
5429 var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
5430
5431 // note the special case: the string '\n' counts as a "trailing" empty line.
5432 var clip = string[string.length - 1] === '\n';
5433 var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
5434 var chomp = keep ? '+' : (clip ? '' : '-');
5435
5436 return indentIndicator + chomp + '\n';
5437}
5438
5439// (See the note for writeScalar.)
5440function dropEndingNewline(string) {
5441 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
5442}
5443
5444// Note: a long line without a suitable break point will exceed the width limit.
5445// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
5446function foldString(string, width) {
5447 // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
5448 // unless they're before or after a more-indented line, or at the very
5449 // beginning or end, in which case $k$ maps to $k$.
5450 // Therefore, parse each chunk as newline(s) followed by a content line.
5451 var lineRe = /(\n+)([^\n]*)/g;
5452
5453 // first line (possibly an empty line)
5454 var result = (function () {
5455 var nextLF = string.indexOf('\n');
5456 nextLF = nextLF !== -1 ? nextLF : string.length;
5457 lineRe.lastIndex = nextLF;
5458 return foldLine(string.slice(0, nextLF), width);
5459 }());
5460 // If we haven't reached the first content line yet, don't add an extra \n.
5461 var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
5462 var moreIndented;
5463
5464 // rest of the lines
5465 var match;
5466 while ((match = lineRe.exec(string))) {
5467 var prefix = match[1], line = match[2];
5468 moreIndented = (line[0] === ' ');
5469 result += prefix
5470 + (!prevMoreIndented && !moreIndented && line !== ''
5471 ? '\n' : '')
5472 + foldLine(line, width);
5473 prevMoreIndented = moreIndented;
5474 }
5475
5476 return result;
5477}
5478
5479// Greedy line breaking.
5480// Picks the longest line under the limit each time,
5481// otherwise settles for the shortest line over the limit.
5482// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
5483function foldLine(line, width) {
5484 if (line === '' || line[0] === ' ') return line;
5485
5486 // Since a more-indented line adds a \n, breaks can't be followed by a space.
5487 var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
5488 var match;
5489 // start is an inclusive index. end, curr, and next are exclusive.
5490 var start = 0, end, curr = 0, next = 0;
5491 var result = '';
5492
5493 // Invariants: 0 <= start <= length-1.
5494 // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
5495 // Inside the loop:
5496 // A match implies length >= 2, so curr and next are <= length-2.
5497 while ((match = breakRe.exec(line))) {
5498 next = match.index;
5499 // maintain invariant: curr - start <= width
5500 if (next - start > width) {
5501 end = (curr > start) ? curr : next; // derive end <= length-2
5502 result += '\n' + line.slice(start, end);
5503 // skip the space that was output as \n
5504 start = end + 1; // derive start <= length-1
5505 }
5506 curr = next;
5507 }
5508
5509 // By the invariants, start <= length-1, so there is something left over.
5510 // It is either the whole string or a part starting from non-whitespace.
5511 result += '\n';
5512 // Insert a break if the remainder is too long and there is a break available.
5513 if (line.length - start > width && curr > start) {
5514 result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
5515 } else {
5516 result += line.slice(start);
5517 }
5518
5519 return result.slice(1); // drop extra \n joiner
5520}
5521
5522// Escapes a double-quoted string.
5523function escapeString(string) {
5524 var result = '';
5525 var char, nextChar;
5526 var escapeSeq;
5527
5528 for (var i = 0; i < string.length; i++) {
5529 char = string.charCodeAt(i);
5530 // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
5531 if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
5532 nextChar = string.charCodeAt(i + 1);
5533 if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
5534 // Combine the surrogate pair and store it escaped.
5535 result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
5536 // Advance index one extra since we already used that char here.
5537 i++; continue;
5538 }
5539 }
5540 escapeSeq = ESCAPE_SEQUENCES[char];
5541 result += !escapeSeq && isPrintable(char)
5542 ? string[i]
5543 : escapeSeq || encodeHex(char);
5544 }
5545
5546 return result;
5547}
5548
5549function writeFlowSequence(state, level, object) {
5550 var _result = '',
5551 _tag = state.tag,
5552 index,
5553 length;
5554
5555 for (index = 0, length = object.length; index < length; index += 1) {
5556 // Write only valid elements.
5557 if (writeNode(state, level, object[index], false, false)) {
5558 if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
5559 _result += state.dump;
5560 }
5561 }
5562
5563 state.tag = _tag;
5564 state.dump = '[' + _result + ']';
5565}
5566
5567function writeBlockSequence(state, level, object, compact) {
5568 var _result = '',
5569 _tag = state.tag,
5570 index,
5571 length;
5572
5573 for (index = 0, length = object.length; index < length; index += 1) {
5574 // Write only valid elements.
5575 if (writeNode(state, level + 1, object[index], true, true)) {
5576 if (!compact || index !== 0) {
5577 _result += generateNextLine(state, level);
5578 }
5579
5580 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
5581 _result += '-';
5582 } else {
5583 _result += '- ';
5584 }
5585
5586 _result += state.dump;
5587 }
5588 }
5589
5590 state.tag = _tag;
5591 state.dump = _result || '[]'; // Empty sequence if no valid values.
5592}
5593
5594function writeFlowMapping(state, level, object) {
5595 var _result = '',
5596 _tag = state.tag,
5597 objectKeyList = Object.keys(object),
5598 index,
5599 length,
5600 objectKey,
5601 objectValue,
5602 pairBuffer;
5603
5604 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
5605 pairBuffer = state.condenseFlow ? '"' : '';
5606
5607 if (index !== 0) pairBuffer += ', ';
5608
5609 objectKey = objectKeyList[index];
5610 objectValue = object[objectKey];
5611
5612 if (!writeNode(state, level, objectKey, false, false)) {
5613 continue; // Skip this pair because of invalid key;
5614 }
5615
5616 if (state.dump.length > 1024) pairBuffer += '? ';
5617
5618 pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
5619
5620 if (!writeNode(state, level, objectValue, false, false)) {
5621 continue; // Skip this pair because of invalid value.
5622 }
5623
5624 pairBuffer += state.dump;
5625
5626 // Both key and value are valid.
5627 _result += pairBuffer;
5628 }
5629
5630 state.tag = _tag;
5631 state.dump = '{' + _result + '}';
5632}
5633
5634function writeBlockMapping(state, level, object, compact) {
5635 var _result = '',
5636 _tag = state.tag,
5637 objectKeyList = Object.keys(object),
5638 index,
5639 length,
5640 objectKey,
5641 objectValue,
5642 explicitPair,
5643 pairBuffer;
5644
5645 // Allow sorting keys so that the output file is deterministic
5646 if (state.sortKeys === true) {
5647 // Default sorting
5648 objectKeyList.sort();
5649 } else if (typeof state.sortKeys === 'function') {
5650 // Custom sort function
5651 objectKeyList.sort(state.sortKeys);
5652 } else if (state.sortKeys) {
5653 // Something is wrong
5654 throw new YAMLException('sortKeys must be a boolean or a function');
5655 }
5656
5657 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
5658 pairBuffer = '';
5659
5660 if (!compact || index !== 0) {
5661 pairBuffer += generateNextLine(state, level);
5662 }
5663
5664 objectKey = objectKeyList[index];
5665 objectValue = object[objectKey];
5666
5667 if (!writeNode(state, level + 1, objectKey, true, true, true)) {
5668 continue; // Skip this pair because of invalid key.
5669 }
5670
5671 explicitPair = (state.tag !== null && state.tag !== '?') ||
5672 (state.dump && state.dump.length > 1024);
5673
5674 if (explicitPair) {
5675 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
5676 pairBuffer += '?';
5677 } else {
5678 pairBuffer += '? ';
5679 }
5680 }
5681
5682 pairBuffer += state.dump;
5683
5684 if (explicitPair) {
5685 pairBuffer += generateNextLine(state, level);
5686 }
5687
5688 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
5689 continue; // Skip this pair because of invalid value.
5690 }
5691
5692 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
5693 pairBuffer += ':';
5694 } else {
5695 pairBuffer += ': ';
5696 }
5697
5698 pairBuffer += state.dump;
5699
5700 // Both key and value are valid.
5701 _result += pairBuffer;
5702 }
5703
5704 state.tag = _tag;
5705 state.dump = _result || '{}'; // Empty mapping if no valid pairs.
5706}
5707
5708function detectType(state, object, explicit) {
5709 var _result, typeList, index, length, type, style;
5710
5711 typeList = explicit ? state.explicitTypes : state.implicitTypes;
5712
5713 for (index = 0, length = typeList.length; index < length; index += 1) {
5714 type = typeList[index];
5715
5716 if ((type.instanceOf || type.predicate) &&
5717 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
5718 (!type.predicate || type.predicate(object))) {
5719
5720 state.tag = explicit ? type.tag : '?';
5721
5722 if (type.represent) {
5723 style = state.styleMap[type.tag] || type.defaultStyle;
5724
5725 if (_toString.call(type.represent) === '[object Function]') {
5726 _result = type.represent(object, style);
5727 } else if (_hasOwnProperty.call(type.represent, style)) {
5728 _result = type.represent[style](object, style);
5729 } else {
5730 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
5731 }
5732
5733 state.dump = _result;
5734 }
5735
5736 return true;
5737 }
5738 }
5739
5740 return false;
5741}
5742
5743// Serializes `object` and writes it to global `result`.
5744// Returns true on success, or false on invalid object.
5745//
5746function writeNode(state, level, object, block, compact, iskey) {
5747 state.tag = null;
5748 state.dump = object;
5749
5750 if (!detectType(state, object, false)) {
5751 detectType(state, object, true);
5752 }
5753
5754 var type = _toString.call(state.dump);
5755
5756 if (block) {
5757 block = (state.flowLevel < 0 || state.flowLevel > level);
5758 }
5759
5760 var objectOrArray = type === '[object Object]' || type === '[object Array]',
5761 duplicateIndex,
5762 duplicate;
5763
5764 if (objectOrArray) {
5765 duplicateIndex = state.duplicates.indexOf(object);
5766 duplicate = duplicateIndex !== -1;
5767 }
5768
5769 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
5770 compact = false;
5771 }
5772
5773 if (duplicate && state.usedDuplicates[duplicateIndex]) {
5774 state.dump = '*ref_' + duplicateIndex;
5775 } else {
5776 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
5777 state.usedDuplicates[duplicateIndex] = true;
5778 }
5779 if (type === '[object Object]') {
5780 if (block && (Object.keys(state.dump).length !== 0)) {
5781 writeBlockMapping(state, level, state.dump, compact);
5782 if (duplicate) {
5783 state.dump = '&ref_' + duplicateIndex + state.dump;
5784 }
5785 } else {
5786 writeFlowMapping(state, level, state.dump);
5787 if (duplicate) {
5788 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
5789 }
5790 }
5791 } else if (type === '[object Array]') {
5792 var arrayLevel = (state.noArrayIndent) ? level - 1 : level;
5793 if (block && (state.dump.length !== 0)) {
5794 writeBlockSequence(state, arrayLevel, state.dump, compact);
5795 if (duplicate) {
5796 state.dump = '&ref_' + duplicateIndex + state.dump;
5797 }
5798 } else {
5799 writeFlowSequence(state, arrayLevel, state.dump);
5800 if (duplicate) {
5801 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
5802 }
5803 }
5804 } else if (type === '[object String]') {
5805 if (state.tag !== '?') {
5806 writeScalar(state, state.dump, level, iskey);
5807 }
5808 } else {
5809 if (state.skipInvalid) return false;
5810 throw new YAMLException('unacceptable kind of an object to dump ' + type);
5811 }
5812
5813 if (state.tag !== null && state.tag !== '?') {
5814 state.dump = '!<' + state.tag + '> ' + state.dump;
5815 }
5816 }
5817
5818 return true;
5819}
5820
5821function getDuplicateReferences(object, state) {
5822 var objects = [],
5823 duplicatesIndexes = [],
5824 index,
5825 length;
5826
5827 inspectNode(object, objects, duplicatesIndexes);
5828
5829 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
5830 state.duplicates.push(objects[duplicatesIndexes[index]]);
5831 }
5832 state.usedDuplicates = new Array(length);
5833}
5834
5835function inspectNode(object, objects, duplicatesIndexes) {
5836 var objectKeyList,
5837 index,
5838 length;
5839
5840 if (object !== null && typeof object === 'object') {
5841 index = objects.indexOf(object);
5842 if (index !== -1) {
5843 if (duplicatesIndexes.indexOf(index) === -1) {
5844 duplicatesIndexes.push(index);
5845 }
5846 } else {
5847 objects.push(object);
5848
5849 if (Array.isArray(object)) {
5850 for (index = 0, length = object.length; index < length; index += 1) {
5851 inspectNode(object[index], objects, duplicatesIndexes);
5852 }
5853 } else {
5854 objectKeyList = Object.keys(object);
5855
5856 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
5857 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
5858 }
5859 }
5860 }
5861 }
5862}
5863
5864function dump(input, options) {
5865 options = options || {};
5866
5867 var state = new State(options);
5868
5869 if (!state.noRefs) getDuplicateReferences(input, state);
5870
5871 if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
5872
5873 return '';
5874}
5875
5876function safeDump(input, options) {
5877 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
5878}
5879
5880module.exports.dump = dump;
5881module.exports.safeDump = safeDump;
5882
5883},{"./common":73,"./exception":75,"./schema/default_full":80,"./schema/default_safe":81}],75:[function(require,module,exports){
5884// YAML error class. http://stackoverflow.com/questions/8458984
5885//
5886'use strict';
5887
5888function YAMLException(reason, mark) {
5889 // Super constructor
5890 Error.call(this);
5891
5892 this.name = 'YAMLException';
5893 this.reason = reason;
5894 this.mark = mark;
5895 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
5896
5897 // Include stack trace in error object
5898 if (Error.captureStackTrace) {
5899 // Chrome and NodeJS
5900 Error.captureStackTrace(this, this.constructor);
5901 } else {
5902 // FF, IE 10+ and Safari 6+. Fallback for others
5903 this.stack = (new Error()).stack || '';
5904 }
5905}
5906
5907
5908// Inherit from Error
5909YAMLException.prototype = Object.create(Error.prototype);
5910YAMLException.prototype.constructor = YAMLException;
5911
5912
5913YAMLException.prototype.toString = function toString(compact) {
5914 var result = this.name + ': ';
5915
5916 result += this.reason || '(unknown reason)';
5917
5918 if (!compact && this.mark) {
5919 result += ' ' + this.mark.toString();
5920 }
5921
5922 return result;
5923};
5924
5925
5926module.exports = YAMLException;
5927
5928},{}],76:[function(require,module,exports){
5929'use strict';
5930
5931/*eslint-disable max-len,no-use-before-define*/
5932
5933var common = require('./common');
5934var YAMLException = require('./exception');
5935var Mark = require('./mark');
5936var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
5937var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
5938
5939
5940var _hasOwnProperty = Object.prototype.hasOwnProperty;
5941
5942
5943var CONTEXT_FLOW_IN = 1;
5944var CONTEXT_FLOW_OUT = 2;
5945var CONTEXT_BLOCK_IN = 3;
5946var CONTEXT_BLOCK_OUT = 4;
5947
5948
5949var CHOMPING_CLIP = 1;
5950var CHOMPING_STRIP = 2;
5951var CHOMPING_KEEP = 3;
5952
5953
5954var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
5955var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
5956var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
5957var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
5958var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
5959
5960
5961function is_EOL(c) {
5962 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
5963}
5964
5965function is_WHITE_SPACE(c) {
5966 return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
5967}
5968
5969function is_WS_OR_EOL(c) {
5970 return (c === 0x09/* Tab */) ||
5971 (c === 0x20/* Space */) ||
5972 (c === 0x0A/* LF */) ||
5973 (c === 0x0D/* CR */);
5974}
5975
5976function is_FLOW_INDICATOR(c) {
5977 return c === 0x2C/* , */ ||
5978 c === 0x5B/* [ */ ||
5979 c === 0x5D/* ] */ ||
5980 c === 0x7B/* { */ ||
5981 c === 0x7D/* } */;
5982}
5983
5984function fromHexCode(c) {
5985 var lc;
5986
5987 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
5988 return c - 0x30;
5989 }
5990
5991 /*eslint-disable no-bitwise*/
5992 lc = c | 0x20;
5993
5994 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
5995 return lc - 0x61 + 10;
5996 }
5997
5998 return -1;
5999}
6000
6001function escapedHexLen(c) {
6002 if (c === 0x78/* x */) { return 2; }
6003 if (c === 0x75/* u */) { return 4; }
6004 if (c === 0x55/* U */) { return 8; }
6005 return 0;
6006}
6007
6008function fromDecimalCode(c) {
6009 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
6010 return c - 0x30;
6011 }
6012
6013 return -1;
6014}
6015
6016function simpleEscapeSequence(c) {
6017 /* eslint-disable indent */
6018 return (c === 0x30/* 0 */) ? '\x00' :
6019 (c === 0x61/* a */) ? '\x07' :
6020 (c === 0x62/* b */) ? '\x08' :
6021 (c === 0x74/* t */) ? '\x09' :
6022 (c === 0x09/* Tab */) ? '\x09' :
6023 (c === 0x6E/* n */) ? '\x0A' :
6024 (c === 0x76/* v */) ? '\x0B' :
6025 (c === 0x66/* f */) ? '\x0C' :
6026 (c === 0x72/* r */) ? '\x0D' :
6027 (c === 0x65/* e */) ? '\x1B' :
6028 (c === 0x20/* Space */) ? ' ' :
6029 (c === 0x22/* " */) ? '\x22' :
6030 (c === 0x2F/* / */) ? '/' :
6031 (c === 0x5C/* \ */) ? '\x5C' :
6032 (c === 0x4E/* N */) ? '\x85' :
6033 (c === 0x5F/* _ */) ? '\xA0' :
6034 (c === 0x4C/* L */) ? '\u2028' :
6035 (c === 0x50/* P */) ? '\u2029' : '';
6036}
6037
6038function charFromCodepoint(c) {
6039 if (c <= 0xFFFF) {
6040 return String.fromCharCode(c);
6041 }
6042 // Encode UTF-16 surrogate pair
6043 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
6044 return String.fromCharCode(
6045 ((c - 0x010000) >> 10) + 0xD800,
6046 ((c - 0x010000) & 0x03FF) + 0xDC00
6047 );
6048}
6049
6050var simpleEscapeCheck = new Array(256); // integer, for fast access
6051var simpleEscapeMap = new Array(256);
6052for (var i = 0; i < 256; i++) {
6053 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
6054 simpleEscapeMap[i] = simpleEscapeSequence(i);
6055}
6056
6057
6058function State(input, options) {
6059 this.input = input;
6060
6061 this.filename = options['filename'] || null;
6062 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
6063 this.onWarning = options['onWarning'] || null;
6064 this.legacy = options['legacy'] || false;
6065 this.json = options['json'] || false;
6066 this.listener = options['listener'] || null;
6067
6068 this.implicitTypes = this.schema.compiledImplicit;
6069 this.typeMap = this.schema.compiledTypeMap;
6070
6071 this.length = input.length;
6072 this.position = 0;
6073 this.line = 0;
6074 this.lineStart = 0;
6075 this.lineIndent = 0;
6076
6077 this.documents = [];
6078
6079 /*
6080 this.version;
6081 this.checkLineBreaks;
6082 this.tagMap;
6083 this.anchorMap;
6084 this.tag;
6085 this.anchor;
6086 this.kind;
6087 this.result;*/
6088
6089}
6090
6091
6092function generateError(state, message) {
6093 return new YAMLException(
6094 message,
6095 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
6096}
6097
6098function throwError(state, message) {
6099 throw generateError(state, message);
6100}
6101
6102function throwWarning(state, message) {
6103 if (state.onWarning) {
6104 state.onWarning.call(null, generateError(state, message));
6105 }
6106}
6107
6108
6109var directiveHandlers = {
6110
6111 YAML: function handleYamlDirective(state, name, args) {
6112
6113 var match, major, minor;
6114
6115 if (state.version !== null) {
6116 throwError(state, 'duplication of %YAML directive');
6117 }
6118
6119 if (args.length !== 1) {
6120 throwError(state, 'YAML directive accepts exactly one argument');
6121 }
6122
6123 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
6124
6125 if (match === null) {
6126 throwError(state, 'ill-formed argument of the YAML directive');
6127 }
6128
6129 major = parseInt(match[1], 10);
6130 minor = parseInt(match[2], 10);
6131
6132 if (major !== 1) {
6133 throwError(state, 'unacceptable YAML version of the document');
6134 }
6135
6136 state.version = args[0];
6137 state.checkLineBreaks = (minor < 2);
6138
6139 if (minor !== 1 && minor !== 2) {
6140 throwWarning(state, 'unsupported YAML version of the document');
6141 }
6142 },
6143
6144 TAG: function handleTagDirective(state, name, args) {
6145
6146 var handle, prefix;
6147
6148 if (args.length !== 2) {
6149 throwError(state, 'TAG directive accepts exactly two arguments');
6150 }
6151
6152 handle = args[0];
6153 prefix = args[1];
6154
6155 if (!PATTERN_TAG_HANDLE.test(handle)) {
6156 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
6157 }
6158
6159 if (_hasOwnProperty.call(state.tagMap, handle)) {
6160 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
6161 }
6162
6163 if (!PATTERN_TAG_URI.test(prefix)) {
6164 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
6165 }
6166
6167 state.tagMap[handle] = prefix;
6168 }
6169};
6170
6171
6172function captureSegment(state, start, end, checkJson) {
6173 var _position, _length, _character, _result;
6174
6175 if (start < end) {
6176 _result = state.input.slice(start, end);
6177
6178 if (checkJson) {
6179 for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
6180 _character = _result.charCodeAt(_position);
6181 if (!(_character === 0x09 ||
6182 (0x20 <= _character && _character <= 0x10FFFF))) {
6183 throwError(state, 'expected valid JSON character');
6184 }
6185 }
6186 } else if (PATTERN_NON_PRINTABLE.test(_result)) {
6187 throwError(state, 'the stream contains non-printable characters');
6188 }
6189
6190 state.result += _result;
6191 }
6192}
6193
6194function mergeMappings(state, destination, source, overridableKeys) {
6195 var sourceKeys, key, index, quantity;
6196
6197 if (!common.isObject(source)) {
6198 throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
6199 }
6200
6201 sourceKeys = Object.keys(source);
6202
6203 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
6204 key = sourceKeys[index];
6205
6206 if (!_hasOwnProperty.call(destination, key)) {
6207 destination[key] = source[key];
6208 overridableKeys[key] = true;
6209 }
6210 }
6211}
6212
6213function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
6214 var index, quantity;
6215
6216 keyNode = String(keyNode);
6217
6218 if (_result === null) {
6219 _result = {};
6220 }
6221
6222 if (keyTag === 'tag:yaml.org,2002:merge') {
6223 if (Array.isArray(valueNode)) {
6224 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
6225 mergeMappings(state, _result, valueNode[index], overridableKeys);
6226 }
6227 } else {
6228 mergeMappings(state, _result, valueNode, overridableKeys);
6229 }
6230 } else {
6231 if (!state.json &&
6232 !_hasOwnProperty.call(overridableKeys, keyNode) &&
6233 _hasOwnProperty.call(_result, keyNode)) {
6234 state.line = startLine || state.line;
6235 state.position = startPos || state.position;
6236 throwError(state, 'duplicated mapping key');
6237 }
6238 _result[keyNode] = valueNode;
6239 delete overridableKeys[keyNode];
6240 }
6241
6242 return _result;
6243}
6244
6245function readLineBreak(state) {
6246 var ch;
6247
6248 ch = state.input.charCodeAt(state.position);
6249
6250 if (ch === 0x0A/* LF */) {
6251 state.position++;
6252 } else if (ch === 0x0D/* CR */) {
6253 state.position++;
6254 if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
6255 state.position++;
6256 }
6257 } else {
6258 throwError(state, 'a line break is expected');
6259 }
6260
6261 state.line += 1;
6262 state.lineStart = state.position;
6263}
6264
6265function skipSeparationSpace(state, allowComments, checkIndent) {
6266 var lineBreaks = 0,
6267 ch = state.input.charCodeAt(state.position);
6268
6269 while (ch !== 0) {
6270 while (is_WHITE_SPACE(ch)) {
6271 ch = state.input.charCodeAt(++state.position);
6272 }
6273
6274 if (allowComments && ch === 0x23/* # */) {
6275 do {
6276 ch = state.input.charCodeAt(++state.position);
6277 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
6278 }
6279
6280 if (is_EOL(ch)) {
6281 readLineBreak(state);
6282
6283 ch = state.input.charCodeAt(state.position);
6284 lineBreaks++;
6285 state.lineIndent = 0;
6286
6287 while (ch === 0x20/* Space */) {
6288 state.lineIndent++;
6289 ch = state.input.charCodeAt(++state.position);
6290 }
6291 } else {
6292 break;
6293 }
6294 }
6295
6296 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
6297 throwWarning(state, 'deficient indentation');
6298 }
6299
6300 return lineBreaks;
6301}
6302
6303function testDocumentSeparator(state) {
6304 var _position = state.position,
6305 ch;
6306
6307 ch = state.input.charCodeAt(_position);
6308
6309 // Condition state.position === state.lineStart is tested
6310 // in parent on each call, for efficiency. No needs to test here again.
6311 if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
6312 ch === state.input.charCodeAt(_position + 1) &&
6313 ch === state.input.charCodeAt(_position + 2)) {
6314
6315 _position += 3;
6316
6317 ch = state.input.charCodeAt(_position);
6318
6319 if (ch === 0 || is_WS_OR_EOL(ch)) {
6320 return true;
6321 }
6322 }
6323
6324 return false;
6325}
6326
6327function writeFoldedLines(state, count) {
6328 if (count === 1) {
6329 state.result += ' ';
6330 } else if (count > 1) {
6331 state.result += common.repeat('\n', count - 1);
6332 }
6333}
6334
6335
6336function readPlainScalar(state, nodeIndent, withinFlowCollection) {
6337 var preceding,
6338 following,
6339 captureStart,
6340 captureEnd,
6341 hasPendingContent,
6342 _line,
6343 _lineStart,
6344 _lineIndent,
6345 _kind = state.kind,
6346 _result = state.result,
6347 ch;
6348
6349 ch = state.input.charCodeAt(state.position);
6350
6351 if (is_WS_OR_EOL(ch) ||
6352 is_FLOW_INDICATOR(ch) ||
6353 ch === 0x23/* # */ ||
6354 ch === 0x26/* & */ ||
6355 ch === 0x2A/* * */ ||
6356 ch === 0x21/* ! */ ||
6357 ch === 0x7C/* | */ ||
6358 ch === 0x3E/* > */ ||
6359 ch === 0x27/* ' */ ||
6360 ch === 0x22/* " */ ||
6361 ch === 0x25/* % */ ||
6362 ch === 0x40/* @ */ ||
6363 ch === 0x60/* ` */) {
6364 return false;
6365 }
6366
6367 if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
6368 following = state.input.charCodeAt(state.position + 1);
6369
6370 if (is_WS_OR_EOL(following) ||
6371 withinFlowCollection && is_FLOW_INDICATOR(following)) {
6372 return false;
6373 }
6374 }
6375
6376 state.kind = 'scalar';
6377 state.result = '';
6378 captureStart = captureEnd = state.position;
6379 hasPendingContent = false;
6380
6381 while (ch !== 0) {
6382 if (ch === 0x3A/* : */) {
6383 following = state.input.charCodeAt(state.position + 1);
6384
6385 if (is_WS_OR_EOL(following) ||
6386 withinFlowCollection && is_FLOW_INDICATOR(following)) {
6387 break;
6388 }
6389
6390 } else if (ch === 0x23/* # */) {
6391 preceding = state.input.charCodeAt(state.position - 1);
6392
6393 if (is_WS_OR_EOL(preceding)) {
6394 break;
6395 }
6396
6397 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
6398 withinFlowCollection && is_FLOW_INDICATOR(ch)) {
6399 break;
6400
6401 } else if (is_EOL(ch)) {
6402 _line = state.line;
6403 _lineStart = state.lineStart;
6404 _lineIndent = state.lineIndent;
6405 skipSeparationSpace(state, false, -1);
6406
6407 if (state.lineIndent >= nodeIndent) {
6408 hasPendingContent = true;
6409 ch = state.input.charCodeAt(state.position);
6410 continue;
6411 } else {
6412 state.position = captureEnd;
6413 state.line = _line;
6414 state.lineStart = _lineStart;
6415 state.lineIndent = _lineIndent;
6416 break;
6417 }
6418 }
6419
6420 if (hasPendingContent) {
6421 captureSegment(state, captureStart, captureEnd, false);
6422 writeFoldedLines(state, state.line - _line);
6423 captureStart = captureEnd = state.position;
6424 hasPendingContent = false;
6425 }
6426
6427 if (!is_WHITE_SPACE(ch)) {
6428 captureEnd = state.position + 1;
6429 }
6430
6431 ch = state.input.charCodeAt(++state.position);
6432 }
6433
6434 captureSegment(state, captureStart, captureEnd, false);
6435
6436 if (state.result) {
6437 return true;
6438 }
6439
6440 state.kind = _kind;
6441 state.result = _result;
6442 return false;
6443}
6444
6445function readSingleQuotedScalar(state, nodeIndent) {
6446 var ch,
6447 captureStart, captureEnd;
6448
6449 ch = state.input.charCodeAt(state.position);
6450
6451 if (ch !== 0x27/* ' */) {
6452 return false;
6453 }
6454
6455 state.kind = 'scalar';
6456 state.result = '';
6457 state.position++;
6458 captureStart = captureEnd = state.position;
6459
6460 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
6461 if (ch === 0x27/* ' */) {
6462 captureSegment(state, captureStart, state.position, true);
6463 ch = state.input.charCodeAt(++state.position);
6464
6465 if (ch === 0x27/* ' */) {
6466 captureStart = state.position;
6467 state.position++;
6468 captureEnd = state.position;
6469 } else {
6470 return true;
6471 }
6472
6473 } else if (is_EOL(ch)) {
6474 captureSegment(state, captureStart, captureEnd, true);
6475 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
6476 captureStart = captureEnd = state.position;
6477
6478 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
6479 throwError(state, 'unexpected end of the document within a single quoted scalar');
6480
6481 } else {
6482 state.position++;
6483 captureEnd = state.position;
6484 }
6485 }
6486
6487 throwError(state, 'unexpected end of the stream within a single quoted scalar');
6488}
6489
6490function readDoubleQuotedScalar(state, nodeIndent) {
6491 var captureStart,
6492 captureEnd,
6493 hexLength,
6494 hexResult,
6495 tmp,
6496 ch;
6497
6498 ch = state.input.charCodeAt(state.position);
6499
6500 if (ch !== 0x22/* " */) {
6501 return false;
6502 }
6503
6504 state.kind = 'scalar';
6505 state.result = '';
6506 state.position++;
6507 captureStart = captureEnd = state.position;
6508
6509 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
6510 if (ch === 0x22/* " */) {
6511 captureSegment(state, captureStart, state.position, true);
6512 state.position++;
6513 return true;
6514
6515 } else if (ch === 0x5C/* \ */) {
6516 captureSegment(state, captureStart, state.position, true);
6517 ch = state.input.charCodeAt(++state.position);
6518
6519 if (is_EOL(ch)) {
6520 skipSeparationSpace(state, false, nodeIndent);
6521
6522 // TODO: rework to inline fn with no type cast?
6523 } else if (ch < 256 && simpleEscapeCheck[ch]) {
6524 state.result += simpleEscapeMap[ch];
6525 state.position++;
6526
6527 } else if ((tmp = escapedHexLen(ch)) > 0) {
6528 hexLength = tmp;
6529 hexResult = 0;
6530
6531 for (; hexLength > 0; hexLength--) {
6532 ch = state.input.charCodeAt(++state.position);
6533
6534 if ((tmp = fromHexCode(ch)) >= 0) {
6535 hexResult = (hexResult << 4) + tmp;
6536
6537 } else {
6538 throwError(state, 'expected hexadecimal character');
6539 }
6540 }
6541
6542 state.result += charFromCodepoint(hexResult);
6543
6544 state.position++;
6545
6546 } else {
6547 throwError(state, 'unknown escape sequence');
6548 }
6549
6550 captureStart = captureEnd = state.position;
6551
6552 } else if (is_EOL(ch)) {
6553 captureSegment(state, captureStart, captureEnd, true);
6554 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
6555 captureStart = captureEnd = state.position;
6556
6557 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
6558 throwError(state, 'unexpected end of the document within a double quoted scalar');
6559
6560 } else {
6561 state.position++;
6562 captureEnd = state.position;
6563 }
6564 }
6565
6566 throwError(state, 'unexpected end of the stream within a double quoted scalar');
6567}
6568
6569function readFlowCollection(state, nodeIndent) {
6570 var readNext = true,
6571 _line,
6572 _tag = state.tag,
6573 _result,
6574 _anchor = state.anchor,
6575 following,
6576 terminator,
6577 isPair,
6578 isExplicitPair,
6579 isMapping,
6580 overridableKeys = {},
6581 keyNode,
6582 keyTag,
6583 valueNode,
6584 ch;
6585
6586 ch = state.input.charCodeAt(state.position);
6587
6588 if (ch === 0x5B/* [ */) {
6589 terminator = 0x5D;/* ] */
6590 isMapping = false;
6591 _result = [];
6592 } else if (ch === 0x7B/* { */) {
6593 terminator = 0x7D;/* } */
6594 isMapping = true;
6595 _result = {};
6596 } else {
6597 return false;
6598 }
6599
6600 if (state.anchor !== null) {
6601 state.anchorMap[state.anchor] = _result;
6602 }
6603
6604 ch = state.input.charCodeAt(++state.position);
6605
6606 while (ch !== 0) {
6607 skipSeparationSpace(state, true, nodeIndent);
6608
6609 ch = state.input.charCodeAt(state.position);
6610
6611 if (ch === terminator) {
6612 state.position++;
6613 state.tag = _tag;
6614 state.anchor = _anchor;
6615 state.kind = isMapping ? 'mapping' : 'sequence';
6616 state.result = _result;
6617 return true;
6618 } else if (!readNext) {
6619 throwError(state, 'missed comma between flow collection entries');
6620 }
6621
6622 keyTag = keyNode = valueNode = null;
6623 isPair = isExplicitPair = false;
6624
6625 if (ch === 0x3F/* ? */) {
6626 following = state.input.charCodeAt(state.position + 1);
6627
6628 if (is_WS_OR_EOL(following)) {
6629 isPair = isExplicitPair = true;
6630 state.position++;
6631 skipSeparationSpace(state, true, nodeIndent);
6632 }
6633 }
6634
6635 _line = state.line;
6636 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
6637 keyTag = state.tag;
6638 keyNode = state.result;
6639 skipSeparationSpace(state, true, nodeIndent);
6640
6641 ch = state.input.charCodeAt(state.position);
6642
6643 if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
6644 isPair = true;
6645 ch = state.input.charCodeAt(++state.position);
6646 skipSeparationSpace(state, true, nodeIndent);
6647 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
6648 valueNode = state.result;
6649 }
6650
6651 if (isMapping) {
6652 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
6653 } else if (isPair) {
6654 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
6655 } else {
6656 _result.push(keyNode);
6657 }
6658
6659 skipSeparationSpace(state, true, nodeIndent);
6660
6661 ch = state.input.charCodeAt(state.position);
6662
6663 if (ch === 0x2C/* , */) {
6664 readNext = true;
6665 ch = state.input.charCodeAt(++state.position);
6666 } else {
6667 readNext = false;
6668 }
6669 }
6670
6671 throwError(state, 'unexpected end of the stream within a flow collection');
6672}
6673
6674function readBlockScalar(state, nodeIndent) {
6675 var captureStart,
6676 folding,
6677 chomping = CHOMPING_CLIP,
6678 didReadContent = false,
6679 detectedIndent = false,
6680 textIndent = nodeIndent,
6681 emptyLines = 0,
6682 atMoreIndented = false,
6683 tmp,
6684 ch;
6685
6686 ch = state.input.charCodeAt(state.position);
6687
6688 if (ch === 0x7C/* | */) {
6689 folding = false;
6690 } else if (ch === 0x3E/* > */) {
6691 folding = true;
6692 } else {
6693 return false;
6694 }
6695
6696 state.kind = 'scalar';
6697 state.result = '';
6698
6699 while (ch !== 0) {
6700 ch = state.input.charCodeAt(++state.position);
6701
6702 if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
6703 if (CHOMPING_CLIP === chomping) {
6704 chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
6705 } else {
6706 throwError(state, 'repeat of a chomping mode identifier');
6707 }
6708
6709 } else if ((tmp = fromDecimalCode(ch)) >= 0) {
6710 if (tmp === 0) {
6711 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
6712 } else if (!detectedIndent) {
6713 textIndent = nodeIndent + tmp - 1;
6714 detectedIndent = true;
6715 } else {
6716 throwError(state, 'repeat of an indentation width identifier');
6717 }
6718
6719 } else {
6720 break;
6721 }
6722 }
6723
6724 if (is_WHITE_SPACE(ch)) {
6725 do { ch = state.input.charCodeAt(++state.position); }
6726 while (is_WHITE_SPACE(ch));
6727
6728 if (ch === 0x23/* # */) {
6729 do { ch = state.input.charCodeAt(++state.position); }
6730 while (!is_EOL(ch) && (ch !== 0));
6731 }
6732 }
6733
6734 while (ch !== 0) {
6735 readLineBreak(state);
6736 state.lineIndent = 0;
6737
6738 ch = state.input.charCodeAt(state.position);
6739
6740 while ((!detectedIndent || state.lineIndent < textIndent) &&
6741 (ch === 0x20/* Space */)) {
6742 state.lineIndent++;
6743 ch = state.input.charCodeAt(++state.position);
6744 }
6745
6746 if (!detectedIndent && state.lineIndent > textIndent) {
6747 textIndent = state.lineIndent;
6748 }
6749
6750 if (is_EOL(ch)) {
6751 emptyLines++;
6752 continue;
6753 }
6754
6755 // End of the scalar.
6756 if (state.lineIndent < textIndent) {
6757
6758 // Perform the chomping.
6759 if (chomping === CHOMPING_KEEP) {
6760 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
6761 } else if (chomping === CHOMPING_CLIP) {
6762 if (didReadContent) { // i.e. only if the scalar is not empty.
6763 state.result += '\n';
6764 }
6765 }
6766
6767 // Break this `while` cycle and go to the funciton's epilogue.
6768 break;
6769 }
6770
6771 // Folded style: use fancy rules to handle line breaks.
6772 if (folding) {
6773
6774 // Lines starting with white space characters (more-indented lines) are not folded.
6775 if (is_WHITE_SPACE(ch)) {
6776 atMoreIndented = true;
6777 // except for the first content line (cf. Example 8.1)
6778 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
6779
6780 // End of more-indented block.
6781 } else if (atMoreIndented) {
6782 atMoreIndented = false;
6783 state.result += common.repeat('\n', emptyLines + 1);
6784
6785 // Just one line break - perceive as the same line.
6786 } else if (emptyLines === 0) {
6787 if (didReadContent) { // i.e. only if we have already read some scalar content.
6788 state.result += ' ';
6789 }
6790
6791 // Several line breaks - perceive as different lines.
6792 } else {
6793 state.result += common.repeat('\n', emptyLines);
6794 }
6795
6796 // Literal style: just add exact number of line breaks between content lines.
6797 } else {
6798 // Keep all line breaks except the header line break.
6799 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
6800 }
6801
6802 didReadContent = true;
6803 detectedIndent = true;
6804 emptyLines = 0;
6805 captureStart = state.position;
6806
6807 while (!is_EOL(ch) && (ch !== 0)) {
6808 ch = state.input.charCodeAt(++state.position);
6809 }
6810
6811 captureSegment(state, captureStart, state.position, false);
6812 }
6813
6814 return true;
6815}
6816
6817function readBlockSequence(state, nodeIndent) {
6818 var _line,
6819 _tag = state.tag,
6820 _anchor = state.anchor,
6821 _result = [],
6822 following,
6823 detected = false,
6824 ch;
6825
6826 if (state.anchor !== null) {
6827 state.anchorMap[state.anchor] = _result;
6828 }
6829
6830 ch = state.input.charCodeAt(state.position);
6831
6832 while (ch !== 0) {
6833
6834 if (ch !== 0x2D/* - */) {
6835 break;
6836 }
6837
6838 following = state.input.charCodeAt(state.position + 1);
6839
6840 if (!is_WS_OR_EOL(following)) {
6841 break;
6842 }
6843
6844 detected = true;
6845 state.position++;
6846
6847 if (skipSeparationSpace(state, true, -1)) {
6848 if (state.lineIndent <= nodeIndent) {
6849 _result.push(null);
6850 ch = state.input.charCodeAt(state.position);
6851 continue;
6852 }
6853 }
6854
6855 _line = state.line;
6856 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
6857 _result.push(state.result);
6858 skipSeparationSpace(state, true, -1);
6859
6860 ch = state.input.charCodeAt(state.position);
6861
6862 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
6863 throwError(state, 'bad indentation of a sequence entry');
6864 } else if (state.lineIndent < nodeIndent) {
6865 break;
6866 }
6867 }
6868
6869 if (detected) {
6870 state.tag = _tag;
6871 state.anchor = _anchor;
6872 state.kind = 'sequence';
6873 state.result = _result;
6874 return true;
6875 }
6876 return false;
6877}
6878
6879function readBlockMapping(state, nodeIndent, flowIndent) {
6880 var following,
6881 allowCompact,
6882 _line,
6883 _pos,
6884 _tag = state.tag,
6885 _anchor = state.anchor,
6886 _result = {},
6887 overridableKeys = {},
6888 keyTag = null,
6889 keyNode = null,
6890 valueNode = null,
6891 atExplicitKey = false,
6892 detected = false,
6893 ch;
6894
6895 if (state.anchor !== null) {
6896 state.anchorMap[state.anchor] = _result;
6897 }
6898
6899 ch = state.input.charCodeAt(state.position);
6900
6901 while (ch !== 0) {
6902 following = state.input.charCodeAt(state.position + 1);
6903 _line = state.line; // Save the current line.
6904 _pos = state.position;
6905
6906 //
6907 // Explicit notation case. There are two separate blocks:
6908 // first for the key (denoted by "?") and second for the value (denoted by ":")
6909 //
6910 if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
6911
6912 if (ch === 0x3F/* ? */) {
6913 if (atExplicitKey) {
6914 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
6915 keyTag = keyNode = valueNode = null;
6916 }
6917
6918 detected = true;
6919 atExplicitKey = true;
6920 allowCompact = true;
6921
6922 } else if (atExplicitKey) {
6923 // i.e. 0x3A/* : */ === character after the explicit key.
6924 atExplicitKey = false;
6925 allowCompact = true;
6926
6927 } else {
6928 throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
6929 }
6930
6931 state.position += 1;
6932 ch = following;
6933
6934 //
6935 // Implicit notation case. Flow-style node as the key first, then ":", and the value.
6936 //
6937 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
6938
6939 if (state.line === _line) {
6940 ch = state.input.charCodeAt(state.position);
6941
6942 while (is_WHITE_SPACE(ch)) {
6943 ch = state.input.charCodeAt(++state.position);
6944 }
6945
6946 if (ch === 0x3A/* : */) {
6947 ch = state.input.charCodeAt(++state.position);
6948
6949 if (!is_WS_OR_EOL(ch)) {
6950 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
6951 }
6952
6953 if (atExplicitKey) {
6954 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
6955 keyTag = keyNode = valueNode = null;
6956 }
6957
6958 detected = true;
6959 atExplicitKey = false;
6960 allowCompact = false;
6961 keyTag = state.tag;
6962 keyNode = state.result;
6963
6964 } else if (detected) {
6965 throwError(state, 'can not read an implicit mapping pair; a colon is missed');
6966
6967 } else {
6968 state.tag = _tag;
6969 state.anchor = _anchor;
6970 return true; // Keep the result of `composeNode`.
6971 }
6972
6973 } else if (detected) {
6974 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
6975
6976 } else {
6977 state.tag = _tag;
6978 state.anchor = _anchor;
6979 return true; // Keep the result of `composeNode`.
6980 }
6981
6982 } else {
6983 break; // Reading is done. Go to the epilogue.
6984 }
6985
6986 //
6987 // Common reading code for both explicit and implicit notations.
6988 //
6989 if (state.line === _line || state.lineIndent > nodeIndent) {
6990 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
6991 if (atExplicitKey) {
6992 keyNode = state.result;
6993 } else {
6994 valueNode = state.result;
6995 }
6996 }
6997
6998 if (!atExplicitKey) {
6999 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
7000 keyTag = keyNode = valueNode = null;
7001 }
7002
7003 skipSeparationSpace(state, true, -1);
7004 ch = state.input.charCodeAt(state.position);
7005 }
7006
7007 if (state.lineIndent > nodeIndent && (ch !== 0)) {
7008 throwError(state, 'bad indentation of a mapping entry');
7009 } else if (state.lineIndent < nodeIndent) {
7010 break;
7011 }
7012 }
7013
7014 //
7015 // Epilogue.
7016 //
7017
7018 // Special case: last mapping's node contains only the key in explicit notation.
7019 if (atExplicitKey) {
7020 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
7021 }
7022
7023 // Expose the resulting mapping.
7024 if (detected) {
7025 state.tag = _tag;
7026 state.anchor = _anchor;
7027 state.kind = 'mapping';
7028 state.result = _result;
7029 }
7030
7031 return detected;
7032}
7033
7034function readTagProperty(state) {
7035 var _position,
7036 isVerbatim = false,
7037 isNamed = false,
7038 tagHandle,
7039 tagName,
7040 ch;
7041
7042 ch = state.input.charCodeAt(state.position);
7043
7044 if (ch !== 0x21/* ! */) return false;
7045
7046 if (state.tag !== null) {
7047 throwError(state, 'duplication of a tag property');
7048 }
7049
7050 ch = state.input.charCodeAt(++state.position);
7051
7052 if (ch === 0x3C/* < */) {
7053 isVerbatim = true;
7054 ch = state.input.charCodeAt(++state.position);
7055
7056 } else if (ch === 0x21/* ! */) {
7057 isNamed = true;
7058 tagHandle = '!!';
7059 ch = state.input.charCodeAt(++state.position);
7060
7061 } else {
7062 tagHandle = '!';
7063 }
7064
7065 _position = state.position;
7066
7067 if (isVerbatim) {
7068 do { ch = state.input.charCodeAt(++state.position); }
7069 while (ch !== 0 && ch !== 0x3E/* > */);
7070
7071 if (state.position < state.length) {
7072 tagName = state.input.slice(_position, state.position);
7073 ch = state.input.charCodeAt(++state.position);
7074 } else {
7075 throwError(state, 'unexpected end of the stream within a verbatim tag');
7076 }
7077 } else {
7078 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
7079
7080 if (ch === 0x21/* ! */) {
7081 if (!isNamed) {
7082 tagHandle = state.input.slice(_position - 1, state.position + 1);
7083
7084 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
7085 throwError(state, 'named tag handle cannot contain such characters');
7086 }
7087
7088 isNamed = true;
7089 _position = state.position + 1;
7090 } else {
7091 throwError(state, 'tag suffix cannot contain exclamation marks');
7092 }
7093 }
7094
7095 ch = state.input.charCodeAt(++state.position);
7096 }
7097
7098 tagName = state.input.slice(_position, state.position);
7099
7100 if (PATTERN_FLOW_INDICATORS.test(tagName)) {
7101 throwError(state, 'tag suffix cannot contain flow indicator characters');
7102 }
7103 }
7104
7105 if (tagName && !PATTERN_TAG_URI.test(tagName)) {
7106 throwError(state, 'tag name cannot contain such characters: ' + tagName);
7107 }
7108
7109 if (isVerbatim) {
7110 state.tag = tagName;
7111
7112 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
7113 state.tag = state.tagMap[tagHandle] + tagName;
7114
7115 } else if (tagHandle === '!') {
7116 state.tag = '!' + tagName;
7117
7118 } else if (tagHandle === '!!') {
7119 state.tag = 'tag:yaml.org,2002:' + tagName;
7120
7121 } else {
7122 throwError(state, 'undeclared tag handle "' + tagHandle + '"');
7123 }
7124
7125 return true;
7126}
7127
7128function readAnchorProperty(state) {
7129 var _position,
7130 ch;
7131
7132 ch = state.input.charCodeAt(state.position);
7133
7134 if (ch !== 0x26/* & */) return false;
7135
7136 if (state.anchor !== null) {
7137 throwError(state, 'duplication of an anchor property');
7138 }
7139
7140 ch = state.input.charCodeAt(++state.position);
7141 _position = state.position;
7142
7143 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
7144 ch = state.input.charCodeAt(++state.position);
7145 }
7146
7147 if (state.position === _position) {
7148 throwError(state, 'name of an anchor node must contain at least one character');
7149 }
7150
7151 state.anchor = state.input.slice(_position, state.position);
7152 return true;
7153}
7154
7155function readAlias(state) {
7156 var _position, alias,
7157 ch;
7158
7159 ch = state.input.charCodeAt(state.position);
7160
7161 if (ch !== 0x2A/* * */) return false;
7162
7163 ch = state.input.charCodeAt(++state.position);
7164 _position = state.position;
7165
7166 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
7167 ch = state.input.charCodeAt(++state.position);
7168 }
7169
7170 if (state.position === _position) {
7171 throwError(state, 'name of an alias node must contain at least one character');
7172 }
7173
7174 alias = state.input.slice(_position, state.position);
7175
7176 if (!state.anchorMap.hasOwnProperty(alias)) {
7177 throwError(state, 'unidentified alias "' + alias + '"');
7178 }
7179
7180 state.result = state.anchorMap[alias];
7181 skipSeparationSpace(state, true, -1);
7182 return true;
7183}
7184
7185function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
7186 var allowBlockStyles,
7187 allowBlockScalars,
7188 allowBlockCollections,
7189 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
7190 atNewLine = false,
7191 hasContent = false,
7192 typeIndex,
7193 typeQuantity,
7194 type,
7195 flowIndent,
7196 blockIndent;
7197
7198 if (state.listener !== null) {
7199 state.listener('open', state);
7200 }
7201
7202 state.tag = null;
7203 state.anchor = null;
7204 state.kind = null;
7205 state.result = null;
7206
7207 allowBlockStyles = allowBlockScalars = allowBlockCollections =
7208 CONTEXT_BLOCK_OUT === nodeContext ||
7209 CONTEXT_BLOCK_IN === nodeContext;
7210
7211 if (allowToSeek) {
7212 if (skipSeparationSpace(state, true, -1)) {
7213 atNewLine = true;
7214
7215 if (state.lineIndent > parentIndent) {
7216 indentStatus = 1;
7217 } else if (state.lineIndent === parentIndent) {
7218 indentStatus = 0;
7219 } else if (state.lineIndent < parentIndent) {
7220 indentStatus = -1;
7221 }
7222 }
7223 }
7224
7225 if (indentStatus === 1) {
7226 while (readTagProperty(state) || readAnchorProperty(state)) {
7227 if (skipSeparationSpace(state, true, -1)) {
7228 atNewLine = true;
7229 allowBlockCollections = allowBlockStyles;
7230
7231 if (state.lineIndent > parentIndent) {
7232 indentStatus = 1;
7233 } else if (state.lineIndent === parentIndent) {
7234 indentStatus = 0;
7235 } else if (state.lineIndent < parentIndent) {
7236 indentStatus = -1;
7237 }
7238 } else {
7239 allowBlockCollections = false;
7240 }
7241 }
7242 }
7243
7244 if (allowBlockCollections) {
7245 allowBlockCollections = atNewLine || allowCompact;
7246 }
7247
7248 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
7249 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
7250 flowIndent = parentIndent;
7251 } else {
7252 flowIndent = parentIndent + 1;
7253 }
7254
7255 blockIndent = state.position - state.lineStart;
7256
7257 if (indentStatus === 1) {
7258 if (allowBlockCollections &&
7259 (readBlockSequence(state, blockIndent) ||
7260 readBlockMapping(state, blockIndent, flowIndent)) ||
7261 readFlowCollection(state, flowIndent)) {
7262 hasContent = true;
7263 } else {
7264 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
7265 readSingleQuotedScalar(state, flowIndent) ||
7266 readDoubleQuotedScalar(state, flowIndent)) {
7267 hasContent = true;
7268
7269 } else if (readAlias(state)) {
7270 hasContent = true;
7271
7272 if (state.tag !== null || state.anchor !== null) {
7273 throwError(state, 'alias node should not have any properties');
7274 }
7275
7276 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
7277 hasContent = true;
7278
7279 if (state.tag === null) {
7280 state.tag = '?';
7281 }
7282 }
7283
7284 if (state.anchor !== null) {
7285 state.anchorMap[state.anchor] = state.result;
7286 }
7287 }
7288 } else if (indentStatus === 0) {
7289 // Special case: block sequences are allowed to have same indentation level as the parent.
7290 // http://www.yaml.org/spec/1.2/spec.html#id2799784
7291 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
7292 }
7293 }
7294
7295 if (state.tag !== null && state.tag !== '!') {
7296 if (state.tag === '?') {
7297 for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
7298 type = state.implicitTypes[typeIndex];
7299
7300 // Implicit resolving is not allowed for non-scalar types, and '?'
7301 // non-specific tag is only assigned to plain scalars. So, it isn't
7302 // needed to check for 'kind' conformity.
7303
7304 if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
7305 state.result = type.construct(state.result);
7306 state.tag = type.tag;
7307 if (state.anchor !== null) {
7308 state.anchorMap[state.anchor] = state.result;
7309 }
7310 break;
7311 }
7312 }
7313 } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
7314 type = state.typeMap[state.kind || 'fallback'][state.tag];
7315
7316 if (state.result !== null && type.kind !== state.kind) {
7317 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
7318 }
7319
7320 if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
7321 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
7322 } else {
7323 state.result = type.construct(state.result);
7324 if (state.anchor !== null) {
7325 state.anchorMap[state.anchor] = state.result;
7326 }
7327 }
7328 } else {
7329 throwError(state, 'unknown tag !<' + state.tag + '>');
7330 }
7331 }
7332
7333 if (state.listener !== null) {
7334 state.listener('close', state);
7335 }
7336 return state.tag !== null || state.anchor !== null || hasContent;
7337}
7338
7339function readDocument(state) {
7340 var documentStart = state.position,
7341 _position,
7342 directiveName,
7343 directiveArgs,
7344 hasDirectives = false,
7345 ch;
7346
7347 state.version = null;
7348 state.checkLineBreaks = state.legacy;
7349 state.tagMap = {};
7350 state.anchorMap = {};
7351
7352 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
7353 skipSeparationSpace(state, true, -1);
7354
7355 ch = state.input.charCodeAt(state.position);
7356
7357 if (state.lineIndent > 0 || ch !== 0x25/* % */) {
7358 break;
7359 }
7360
7361 hasDirectives = true;
7362 ch = state.input.charCodeAt(++state.position);
7363 _position = state.position;
7364
7365 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
7366 ch = state.input.charCodeAt(++state.position);
7367 }
7368
7369 directiveName = state.input.slice(_position, state.position);
7370 directiveArgs = [];
7371
7372 if (directiveName.length < 1) {
7373 throwError(state, 'directive name must not be less than one character in length');
7374 }
7375
7376 while (ch !== 0) {
7377 while (is_WHITE_SPACE(ch)) {
7378 ch = state.input.charCodeAt(++state.position);
7379 }
7380
7381 if (ch === 0x23/* # */) {
7382 do { ch = state.input.charCodeAt(++state.position); }
7383 while (ch !== 0 && !is_EOL(ch));
7384 break;
7385 }
7386
7387 if (is_EOL(ch)) break;
7388
7389 _position = state.position;
7390
7391 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
7392 ch = state.input.charCodeAt(++state.position);
7393 }
7394
7395 directiveArgs.push(state.input.slice(_position, state.position));
7396 }
7397
7398 if (ch !== 0) readLineBreak(state);
7399
7400 if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
7401 directiveHandlers[directiveName](state, directiveName, directiveArgs);
7402 } else {
7403 throwWarning(state, 'unknown document directive "' + directiveName + '"');
7404 }
7405 }
7406
7407 skipSeparationSpace(state, true, -1);
7408
7409 if (state.lineIndent === 0 &&
7410 state.input.charCodeAt(state.position) === 0x2D/* - */ &&
7411 state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
7412 state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
7413 state.position += 3;
7414 skipSeparationSpace(state, true, -1);
7415
7416 } else if (hasDirectives) {
7417 throwError(state, 'directives end mark is expected');
7418 }
7419
7420 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
7421 skipSeparationSpace(state, true, -1);
7422
7423 if (state.checkLineBreaks &&
7424 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
7425 throwWarning(state, 'non-ASCII line breaks are interpreted as content');
7426 }
7427
7428 state.documents.push(state.result);
7429
7430 if (state.position === state.lineStart && testDocumentSeparator(state)) {
7431
7432 if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
7433 state.position += 3;
7434 skipSeparationSpace(state, true, -1);
7435 }
7436 return;
7437 }
7438
7439 if (state.position < (state.length - 1)) {
7440 throwError(state, 'end of the stream or a document separator is expected');
7441 } else {
7442 return;
7443 }
7444}
7445
7446
7447function loadDocuments(input, options) {
7448 input = String(input);
7449 options = options || {};
7450
7451 if (input.length !== 0) {
7452
7453 // Add tailing `\n` if not exists
7454 if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
7455 input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
7456 input += '\n';
7457 }
7458
7459 // Strip BOM
7460 if (input.charCodeAt(0) === 0xFEFF) {
7461 input = input.slice(1);
7462 }
7463 }
7464
7465 var state = new State(input, options);
7466
7467 // Use 0 as string terminator. That significantly simplifies bounds check.
7468 state.input += '\0';
7469
7470 while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
7471 state.lineIndent += 1;
7472 state.position += 1;
7473 }
7474
7475 while (state.position < (state.length - 1)) {
7476 readDocument(state);
7477 }
7478
7479 return state.documents;
7480}
7481
7482
7483function loadAll(input, iterator, options) {
7484 var documents = loadDocuments(input, options), index, length;
7485
7486 if (typeof iterator !== 'function') {
7487 return documents;
7488 }
7489
7490 for (index = 0, length = documents.length; index < length; index += 1) {
7491 iterator(documents[index]);
7492 }
7493}
7494
7495
7496function load(input, options) {
7497 var documents = loadDocuments(input, options);
7498
7499 if (documents.length === 0) {
7500 /*eslint-disable no-undefined*/
7501 return undefined;
7502 } else if (documents.length === 1) {
7503 return documents[0];
7504 }
7505 throw new YAMLException('expected a single document in the stream, but found more');
7506}
7507
7508
7509function safeLoadAll(input, output, options) {
7510 if (typeof output === 'function') {
7511 loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
7512 } else {
7513 return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
7514 }
7515}
7516
7517
7518function safeLoad(input, options) {
7519 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
7520}
7521
7522
7523module.exports.loadAll = loadAll;
7524module.exports.load = load;
7525module.exports.safeLoadAll = safeLoadAll;
7526module.exports.safeLoad = safeLoad;
7527
7528},{"./common":73,"./exception":75,"./mark":77,"./schema/default_full":80,"./schema/default_safe":81}],77:[function(require,module,exports){
7529'use strict';
7530
7531
7532var common = require('./common');
7533
7534
7535function Mark(name, buffer, position, line, column) {
7536 this.name = name;
7537 this.buffer = buffer;
7538 this.position = position;
7539 this.line = line;
7540 this.column = column;
7541}
7542
7543
7544Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
7545 var head, start, tail, end, snippet;
7546
7547 if (!this.buffer) return null;
7548
7549 indent = indent || 4;
7550 maxLength = maxLength || 75;
7551
7552 head = '';
7553 start = this.position;
7554
7555 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
7556 start -= 1;
7557 if (this.position - start > (maxLength / 2 - 1)) {
7558 head = ' ... ';
7559 start += 5;
7560 break;
7561 }
7562 }
7563
7564 tail = '';
7565 end = this.position;
7566
7567 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
7568 end += 1;
7569 if (end - this.position > (maxLength / 2 - 1)) {
7570 tail = ' ... ';
7571 end -= 5;
7572 break;
7573 }
7574 }
7575
7576 snippet = this.buffer.slice(start, end);
7577
7578 return common.repeat(' ', indent) + head + snippet + tail + '\n' +
7579 common.repeat(' ', indent + this.position - start + head.length) + '^';
7580};
7581
7582
7583Mark.prototype.toString = function toString(compact) {
7584 var snippet, where = '';
7585
7586 if (this.name) {
7587 where += 'in "' + this.name + '" ';
7588 }
7589
7590 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
7591
7592 if (!compact) {
7593 snippet = this.getSnippet();
7594
7595 if (snippet) {
7596 where += ':\n' + snippet;
7597 }
7598 }
7599
7600 return where;
7601};
7602
7603
7604module.exports = Mark;
7605
7606},{"./common":73}],78:[function(require,module,exports){
7607'use strict';
7608
7609/*eslint-disable max-len*/
7610
7611var common = require('./common');
7612var YAMLException = require('./exception');
7613var Type = require('./type');
7614
7615
7616function compileList(schema, name, result) {
7617 var exclude = [];
7618
7619 schema.include.forEach(function (includedSchema) {
7620 result = compileList(includedSchema, name, result);
7621 });
7622
7623 schema[name].forEach(function (currentType) {
7624 result.forEach(function (previousType, previousIndex) {
7625 if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
7626 exclude.push(previousIndex);
7627 }
7628 });
7629
7630 result.push(currentType);
7631 });
7632
7633 return result.filter(function (type, index) {
7634 return exclude.indexOf(index) === -1;
7635 });
7636}
7637
7638
7639function compileMap(/* lists... */) {
7640 var result = {
7641 scalar: {},
7642 sequence: {},
7643 mapping: {},
7644 fallback: {}
7645 }, index, length;
7646
7647 function collectType(type) {
7648 result[type.kind][type.tag] = result['fallback'][type.tag] = type;
7649 }
7650
7651 for (index = 0, length = arguments.length; index < length; index += 1) {
7652 arguments[index].forEach(collectType);
7653 }
7654 return result;
7655}
7656
7657
7658function Schema(definition) {
7659 this.include = definition.include || [];
7660 this.implicit = definition.implicit || [];
7661 this.explicit = definition.explicit || [];
7662
7663 this.implicit.forEach(function (type) {
7664 if (type.loadKind && type.loadKind !== 'scalar') {
7665 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
7666 }
7667 });
7668
7669 this.compiledImplicit = compileList(this, 'implicit', []);
7670 this.compiledExplicit = compileList(this, 'explicit', []);
7671 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
7672}
7673
7674
7675Schema.DEFAULT = null;
7676
7677
7678Schema.create = function createSchema() {
7679 var schemas, types;
7680
7681 switch (arguments.length) {
7682 case 1:
7683 schemas = Schema.DEFAULT;
7684 types = arguments[0];
7685 break;
7686
7687 case 2:
7688 schemas = arguments[0];
7689 types = arguments[1];
7690 break;
7691
7692 default:
7693 throw new YAMLException('Wrong number of arguments for Schema.create function');
7694 }
7695
7696 schemas = common.toArray(schemas);
7697 types = common.toArray(types);
7698
7699 if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
7700 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
7701 }
7702
7703 if (!types.every(function (type) { return type instanceof Type; })) {
7704 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
7705 }
7706
7707 return new Schema({
7708 include: schemas,
7709 explicit: types
7710 });
7711};
7712
7713
7714module.exports = Schema;
7715
7716},{"./common":73,"./exception":75,"./type":84}],79:[function(require,module,exports){
7717// Standard YAML's Core schema.
7718// http://www.yaml.org/spec/1.2/spec.html#id2804923
7719//
7720// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
7721// So, Core schema has no distinctions from JSON schema is JS-YAML.
7722
7723
7724'use strict';
7725
7726
7727var Schema = require('../schema');
7728
7729
7730module.exports = new Schema({
7731 include: [
7732 require('./json')
7733 ]
7734});
7735
7736},{"../schema":78,"./json":83}],80:[function(require,module,exports){
7737// JS-YAML's default schema for `load` function.
7738// It is not described in the YAML specification.
7739//
7740// This schema is based on JS-YAML's default safe schema and includes
7741// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
7742//
7743// Also this schema is used as default base schema at `Schema.create` function.
7744
7745
7746'use strict';
7747
7748
7749var Schema = require('../schema');
7750
7751
7752module.exports = Schema.DEFAULT = new Schema({
7753 include: [
7754 require('./default_safe')
7755 ],
7756 explicit: [
7757 require('../type/js/undefined'),
7758 require('../type/js/regexp'),
7759 require('../type/js/function')
7760 ]
7761});
7762
7763},{"../schema":78,"../type/js/function":89,"../type/js/regexp":90,"../type/js/undefined":91,"./default_safe":81}],81:[function(require,module,exports){
7764// JS-YAML's default schema for `safeLoad` function.
7765// It is not described in the YAML specification.
7766//
7767// This schema is based on standard YAML's Core schema and includes most of
7768// extra types described at YAML tag repository. (http://yaml.org/type/)
7769
7770
7771'use strict';
7772
7773
7774var Schema = require('../schema');
7775
7776
7777module.exports = new Schema({
7778 include: [
7779 require('./core')
7780 ],
7781 implicit: [
7782 require('../type/timestamp'),
7783 require('../type/merge')
7784 ],
7785 explicit: [
7786 require('../type/binary'),
7787 require('../type/omap'),
7788 require('../type/pairs'),
7789 require('../type/set')
7790 ]
7791});
7792
7793},{"../schema":78,"../type/binary":85,"../type/merge":93,"../type/omap":95,"../type/pairs":96,"../type/set":98,"../type/timestamp":100,"./core":79}],82:[function(require,module,exports){
7794// Standard YAML's Failsafe schema.
7795// http://www.yaml.org/spec/1.2/spec.html#id2802346
7796
7797
7798'use strict';
7799
7800
7801var Schema = require('../schema');
7802
7803
7804module.exports = new Schema({
7805 explicit: [
7806 require('../type/str'),
7807 require('../type/seq'),
7808 require('../type/map')
7809 ]
7810});
7811
7812},{"../schema":78,"../type/map":92,"../type/seq":97,"../type/str":99}],83:[function(require,module,exports){
7813// Standard YAML's JSON schema.
7814// http://www.yaml.org/spec/1.2/spec.html#id2803231
7815//
7816// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
7817// So, this schema is not such strict as defined in the YAML specification.
7818// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
7819
7820
7821'use strict';
7822
7823
7824var Schema = require('../schema');
7825
7826
7827module.exports = new Schema({
7828 include: [
7829 require('./failsafe')
7830 ],
7831 implicit: [
7832 require('../type/null'),
7833 require('../type/bool'),
7834 require('../type/int'),
7835 require('../type/float')
7836 ]
7837});
7838
7839},{"../schema":78,"../type/bool":86,"../type/float":87,"../type/int":88,"../type/null":94,"./failsafe":82}],84:[function(require,module,exports){
7840'use strict';
7841
7842var YAMLException = require('./exception');
7843
7844var TYPE_CONSTRUCTOR_OPTIONS = [
7845 'kind',
7846 'resolve',
7847 'construct',
7848 'instanceOf',
7849 'predicate',
7850 'represent',
7851 'defaultStyle',
7852 'styleAliases'
7853];
7854
7855var YAML_NODE_KINDS = [
7856 'scalar',
7857 'sequence',
7858 'mapping'
7859];
7860
7861function compileStyleAliases(map) {
7862 var result = {};
7863
7864 if (map !== null) {
7865 Object.keys(map).forEach(function (style) {
7866 map[style].forEach(function (alias) {
7867 result[String(alias)] = style;
7868 });
7869 });
7870 }
7871
7872 return result;
7873}
7874
7875function Type(tag, options) {
7876 options = options || {};
7877
7878 Object.keys(options).forEach(function (name) {
7879 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
7880 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
7881 }
7882 });
7883
7884 // TODO: Add tag format check.
7885 this.tag = tag;
7886 this.kind = options['kind'] || null;
7887 this.resolve = options['resolve'] || function () { return true; };
7888 this.construct = options['construct'] || function (data) { return data; };
7889 this.instanceOf = options['instanceOf'] || null;
7890 this.predicate = options['predicate'] || null;
7891 this.represent = options['represent'] || null;
7892 this.defaultStyle = options['defaultStyle'] || null;
7893 this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
7894
7895 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
7896 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
7897 }
7898}
7899
7900module.exports = Type;
7901
7902},{"./exception":75}],85:[function(require,module,exports){
7903'use strict';
7904
7905/*eslint-disable no-bitwise*/
7906
7907var NodeBuffer;
7908
7909try {
7910 // A trick for browserified version, to not include `Buffer` shim
7911 var _require = require;
7912 NodeBuffer = _require('buffer').Buffer;
7913} catch (__) {}
7914
7915var Type = require('../type');
7916
7917
7918// [ 64, 65, 66 ] -> [ padding, CR, LF ]
7919var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
7920
7921
7922function resolveYamlBinary(data) {
7923 if (data === null) return false;
7924
7925 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
7926
7927 // Convert one by one.
7928 for (idx = 0; idx < max; idx++) {
7929 code = map.indexOf(data.charAt(idx));
7930
7931 // Skip CR/LF
7932 if (code > 64) continue;
7933
7934 // Fail on illegal characters
7935 if (code < 0) return false;
7936
7937 bitlen += 6;
7938 }
7939
7940 // If there are any bits left, source was corrupted
7941 return (bitlen % 8) === 0;
7942}
7943
7944function constructYamlBinary(data) {
7945 var idx, tailbits,
7946 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
7947 max = input.length,
7948 map = BASE64_MAP,
7949 bits = 0,
7950 result = [];
7951
7952 // Collect by 6*4 bits (3 bytes)
7953
7954 for (idx = 0; idx < max; idx++) {
7955 if ((idx % 4 === 0) && idx) {
7956 result.push((bits >> 16) & 0xFF);
7957 result.push((bits >> 8) & 0xFF);
7958 result.push(bits & 0xFF);
7959 }
7960
7961 bits = (bits << 6) | map.indexOf(input.charAt(idx));
7962 }
7963
7964 // Dump tail
7965
7966 tailbits = (max % 4) * 6;
7967
7968 if (tailbits === 0) {
7969 result.push((bits >> 16) & 0xFF);
7970 result.push((bits >> 8) & 0xFF);
7971 result.push(bits & 0xFF);
7972 } else if (tailbits === 18) {
7973 result.push((bits >> 10) & 0xFF);
7974 result.push((bits >> 2) & 0xFF);
7975 } else if (tailbits === 12) {
7976 result.push((bits >> 4) & 0xFF);
7977 }
7978
7979 // Wrap into Buffer for NodeJS and leave Array for browser
7980 if (NodeBuffer) {
7981 // Support node 6.+ Buffer API when available
7982 return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
7983 }
7984
7985 return result;
7986}
7987
7988function representYamlBinary(object /*, style*/) {
7989 var result = '', bits = 0, idx, tail,
7990 max = object.length,
7991 map = BASE64_MAP;
7992
7993 // Convert every three bytes to 4 ASCII characters.
7994
7995 for (idx = 0; idx < max; idx++) {
7996 if ((idx % 3 === 0) && idx) {
7997 result += map[(bits >> 18) & 0x3F];
7998 result += map[(bits >> 12) & 0x3F];
7999 result += map[(bits >> 6) & 0x3F];
8000 result += map[bits & 0x3F];
8001 }
8002
8003 bits = (bits << 8) + object[idx];
8004 }
8005
8006 // Dump tail
8007
8008 tail = max % 3;
8009
8010 if (tail === 0) {
8011 result += map[(bits >> 18) & 0x3F];
8012 result += map[(bits >> 12) & 0x3F];
8013 result += map[(bits >> 6) & 0x3F];
8014 result += map[bits & 0x3F];
8015 } else if (tail === 2) {
8016 result += map[(bits >> 10) & 0x3F];
8017 result += map[(bits >> 4) & 0x3F];
8018 result += map[(bits << 2) & 0x3F];
8019 result += map[64];
8020 } else if (tail === 1) {
8021 result += map[(bits >> 2) & 0x3F];
8022 result += map[(bits << 4) & 0x3F];
8023 result += map[64];
8024 result += map[64];
8025 }
8026
8027 return result;
8028}
8029
8030function isBinary(object) {
8031 return NodeBuffer && NodeBuffer.isBuffer(object);
8032}
8033
8034module.exports = new Type('tag:yaml.org,2002:binary', {
8035 kind: 'scalar',
8036 resolve: resolveYamlBinary,
8037 construct: constructYamlBinary,
8038 predicate: isBinary,
8039 represent: representYamlBinary
8040});
8041
8042},{"../type":84}],86:[function(require,module,exports){
8043'use strict';
8044
8045var Type = require('../type');
8046
8047function resolveYamlBoolean(data) {
8048 if (data === null) return false;
8049
8050 var max = data.length;
8051
8052 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
8053 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
8054}
8055
8056function constructYamlBoolean(data) {
8057 return data === 'true' ||
8058 data === 'True' ||
8059 data === 'TRUE';
8060}
8061
8062function isBoolean(object) {
8063 return Object.prototype.toString.call(object) === '[object Boolean]';
8064}
8065
8066module.exports = new Type('tag:yaml.org,2002:bool', {
8067 kind: 'scalar',
8068 resolve: resolveYamlBoolean,
8069 construct: constructYamlBoolean,
8070 predicate: isBoolean,
8071 represent: {
8072 lowercase: function (object) { return object ? 'true' : 'false'; },
8073 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
8074 camelcase: function (object) { return object ? 'True' : 'False'; }
8075 },
8076 defaultStyle: 'lowercase'
8077});
8078
8079},{"../type":84}],87:[function(require,module,exports){
8080'use strict';
8081
8082var common = require('../common');
8083var Type = require('../type');
8084
8085var YAML_FLOAT_PATTERN = new RegExp(
8086 // 2.5e4, 2.5 and integers
8087 '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
8088 // .2e4, .2
8089 // special case, seems not from spec
8090 '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
8091 // 20:59
8092 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
8093 // .inf
8094 '|[-+]?\\.(?:inf|Inf|INF)' +
8095 // .nan
8096 '|\\.(?:nan|NaN|NAN))$');
8097
8098function resolveYamlFloat(data) {
8099 if (data === null) return false;
8100
8101 if (!YAML_FLOAT_PATTERN.test(data) ||
8102 // Quick hack to not allow integers end with `_`
8103 // Probably should update regexp & check speed
8104 data[data.length - 1] === '_') {
8105 return false;
8106 }
8107
8108 return true;
8109}
8110
8111function constructYamlFloat(data) {
8112 var value, sign, base, digits;
8113
8114 value = data.replace(/_/g, '').toLowerCase();
8115 sign = value[0] === '-' ? -1 : 1;
8116 digits = [];
8117
8118 if ('+-'.indexOf(value[0]) >= 0) {
8119 value = value.slice(1);
8120 }
8121
8122 if (value === '.inf') {
8123 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
8124
8125 } else if (value === '.nan') {
8126 return NaN;
8127
8128 } else if (value.indexOf(':') >= 0) {
8129 value.split(':').forEach(function (v) {
8130 digits.unshift(parseFloat(v, 10));
8131 });
8132
8133 value = 0.0;
8134 base = 1;
8135
8136 digits.forEach(function (d) {
8137 value += d * base;
8138 base *= 60;
8139 });
8140
8141 return sign * value;
8142
8143 }
8144 return sign * parseFloat(value, 10);
8145}
8146
8147
8148var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
8149
8150function representYamlFloat(object, style) {
8151 var res;
8152
8153 if (isNaN(object)) {
8154 switch (style) {
8155 case 'lowercase': return '.nan';
8156 case 'uppercase': return '.NAN';
8157 case 'camelcase': return '.NaN';
8158 }
8159 } else if (Number.POSITIVE_INFINITY === object) {
8160 switch (style) {
8161 case 'lowercase': return '.inf';
8162 case 'uppercase': return '.INF';
8163 case 'camelcase': return '.Inf';
8164 }
8165 } else if (Number.NEGATIVE_INFINITY === object) {
8166 switch (style) {
8167 case 'lowercase': return '-.inf';
8168 case 'uppercase': return '-.INF';
8169 case 'camelcase': return '-.Inf';
8170 }
8171 } else if (common.isNegativeZero(object)) {
8172 return '-0.0';
8173 }
8174
8175 res = object.toString(10);
8176
8177 // JS stringifier can build scientific format without dots: 5e-100,
8178 // while YAML requres dot: 5.e-100. Fix it with simple hack
8179
8180 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
8181}
8182
8183function isFloat(object) {
8184 return (Object.prototype.toString.call(object) === '[object Number]') &&
8185 (object % 1 !== 0 || common.isNegativeZero(object));
8186}
8187
8188module.exports = new Type('tag:yaml.org,2002:float', {
8189 kind: 'scalar',
8190 resolve: resolveYamlFloat,
8191 construct: constructYamlFloat,
8192 predicate: isFloat,
8193 represent: representYamlFloat,
8194 defaultStyle: 'lowercase'
8195});
8196
8197},{"../common":73,"../type":84}],88:[function(require,module,exports){
8198'use strict';
8199
8200var common = require('../common');
8201var Type = require('../type');
8202
8203function isHexCode(c) {
8204 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
8205 ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
8206 ((0x61/* a */ <= c) && (c <= 0x66/* f */));
8207}
8208
8209function isOctCode(c) {
8210 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
8211}
8212
8213function isDecCode(c) {
8214 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
8215}
8216
8217function resolveYamlInteger(data) {
8218 if (data === null) return false;
8219
8220 var max = data.length,
8221 index = 0,
8222 hasDigits = false,
8223 ch;
8224
8225 if (!max) return false;
8226
8227 ch = data[index];
8228
8229 // sign
8230 if (ch === '-' || ch === '+') {
8231 ch = data[++index];
8232 }
8233
8234 if (ch === '0') {
8235 // 0
8236 if (index + 1 === max) return true;
8237 ch = data[++index];
8238
8239 // base 2, base 8, base 16
8240
8241 if (ch === 'b') {
8242 // base 2
8243 index++;
8244
8245 for (; index < max; index++) {
8246 ch = data[index];
8247 if (ch === '_') continue;
8248 if (ch !== '0' && ch !== '1') return false;
8249 hasDigits = true;
8250 }
8251 return hasDigits && ch !== '_';
8252 }
8253
8254
8255 if (ch === 'x') {
8256 // base 16
8257 index++;
8258
8259 for (; index < max; index++) {
8260 ch = data[index];
8261 if (ch === '_') continue;
8262 if (!isHexCode(data.charCodeAt(index))) return false;
8263 hasDigits = true;
8264 }
8265 return hasDigits && ch !== '_';
8266 }
8267
8268 // base 8
8269 for (; index < max; index++) {
8270 ch = data[index];
8271 if (ch === '_') continue;
8272 if (!isOctCode(data.charCodeAt(index))) return false;
8273 hasDigits = true;
8274 }
8275 return hasDigits && ch !== '_';
8276 }
8277
8278 // base 10 (except 0) or base 60
8279
8280 // value should not start with `_`;
8281 if (ch === '_') return false;
8282
8283 for (; index < max; index++) {
8284 ch = data[index];
8285 if (ch === '_') continue;
8286 if (ch === ':') break;
8287 if (!isDecCode(data.charCodeAt(index))) {
8288 return false;
8289 }
8290 hasDigits = true;
8291 }
8292
8293 // Should have digits and should not end with `_`
8294 if (!hasDigits || ch === '_') return false;
8295
8296 // if !base60 - done;
8297 if (ch !== ':') return true;
8298
8299 // base60 almost not used, no needs to optimize
8300 return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
8301}
8302
8303function constructYamlInteger(data) {
8304 var value = data, sign = 1, ch, base, digits = [];
8305
8306 if (value.indexOf('_') !== -1) {
8307 value = value.replace(/_/g, '');
8308 }
8309
8310 ch = value[0];
8311
8312 if (ch === '-' || ch === '+') {
8313 if (ch === '-') sign = -1;
8314 value = value.slice(1);
8315 ch = value[0];
8316 }
8317
8318 if (value === '0') return 0;
8319
8320 if (ch === '0') {
8321 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
8322 if (value[1] === 'x') return sign * parseInt(value, 16);
8323 return sign * parseInt(value, 8);
8324 }
8325
8326 if (value.indexOf(':') !== -1) {
8327 value.split(':').forEach(function (v) {
8328 digits.unshift(parseInt(v, 10));
8329 });
8330
8331 value = 0;
8332 base = 1;
8333
8334 digits.forEach(function (d) {
8335 value += (d * base);
8336 base *= 60;
8337 });
8338
8339 return sign * value;
8340
8341 }
8342
8343 return sign * parseInt(value, 10);
8344}
8345
8346function isInteger(object) {
8347 return (Object.prototype.toString.call(object)) === '[object Number]' &&
8348 (object % 1 === 0 && !common.isNegativeZero(object));
8349}
8350
8351module.exports = new Type('tag:yaml.org,2002:int', {
8352 kind: 'scalar',
8353 resolve: resolveYamlInteger,
8354 construct: constructYamlInteger,
8355 predicate: isInteger,
8356 represent: {
8357 binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
8358 octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
8359 decimal: function (obj) { return obj.toString(10); },
8360 /* eslint-disable max-len */
8361 hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
8362 },
8363 defaultStyle: 'decimal',
8364 styleAliases: {
8365 binary: [ 2, 'bin' ],
8366 octal: [ 8, 'oct' ],
8367 decimal: [ 10, 'dec' ],
8368 hexadecimal: [ 16, 'hex' ]
8369 }
8370});
8371
8372},{"../common":73,"../type":84}],89:[function(require,module,exports){
8373'use strict';
8374
8375var esprima;
8376
8377// Browserified version does not have esprima
8378//
8379// 1. For node.js just require module as deps
8380// 2. For browser try to require mudule via external AMD system.
8381// If not found - try to fallback to window.esprima. If not
8382// found too - then fail to parse.
8383//
8384try {
8385 // workaround to exclude package from browserify list.
8386 var _require = require;
8387 esprima = _require('esprima');
8388} catch (_) {
8389 /*global window */
8390 if (typeof window !== 'undefined') esprima = window.esprima;
8391}
8392
8393var Type = require('../../type');
8394
8395function resolveJavascriptFunction(data) {
8396 if (data === null) return false;
8397
8398 try {
8399 var source = '(' + data + ')',
8400 ast = esprima.parse(source, { range: true });
8401
8402 if (ast.type !== 'Program' ||
8403 ast.body.length !== 1 ||
8404 ast.body[0].type !== 'ExpressionStatement' ||
8405 (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
8406 ast.body[0].expression.type !== 'FunctionExpression')) {
8407 return false;
8408 }
8409
8410 return true;
8411 } catch (err) {
8412 return false;
8413 }
8414}
8415
8416function constructJavascriptFunction(data) {
8417 /*jslint evil:true*/
8418
8419 var source = '(' + data + ')',
8420 ast = esprima.parse(source, { range: true }),
8421 params = [],
8422 body;
8423
8424 if (ast.type !== 'Program' ||
8425 ast.body.length !== 1 ||
8426 ast.body[0].type !== 'ExpressionStatement' ||
8427 (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
8428 ast.body[0].expression.type !== 'FunctionExpression')) {
8429 throw new Error('Failed to resolve function');
8430 }
8431
8432 ast.body[0].expression.params.forEach(function (param) {
8433 params.push(param.name);
8434 });
8435
8436 body = ast.body[0].expression.body.range;
8437
8438 // Esprima's ranges include the first '{' and the last '}' characters on
8439 // function expressions. So cut them out.
8440 if (ast.body[0].expression.body.type === 'BlockStatement') {
8441 /*eslint-disable no-new-func*/
8442 return new Function(params, source.slice(body[0] + 1, body[1] - 1));
8443 }
8444 // ES6 arrow functions can omit the BlockStatement. In that case, just return
8445 // the body.
8446 /*eslint-disable no-new-func*/
8447 return new Function(params, 'return ' + source.slice(body[0], body[1]));
8448}
8449
8450function representJavascriptFunction(object /*, style*/) {
8451 return object.toString();
8452}
8453
8454function isFunction(object) {
8455 return Object.prototype.toString.call(object) === '[object Function]';
8456}
8457
8458module.exports = new Type('tag:yaml.org,2002:js/function', {
8459 kind: 'scalar',
8460 resolve: resolveJavascriptFunction,
8461 construct: constructJavascriptFunction,
8462 predicate: isFunction,
8463 represent: representJavascriptFunction
8464});
8465
8466},{"../../type":84}],90:[function(require,module,exports){
8467'use strict';
8468
8469var Type = require('../../type');
8470
8471function resolveJavascriptRegExp(data) {
8472 if (data === null) return false;
8473 if (data.length === 0) return false;
8474
8475 var regexp = data,
8476 tail = /\/([gim]*)$/.exec(data),
8477 modifiers = '';
8478
8479 // if regexp starts with '/' it can have modifiers and must be properly closed
8480 // `/foo/gim` - modifiers tail can be maximum 3 chars
8481 if (regexp[0] === '/') {
8482 if (tail) modifiers = tail[1];
8483
8484 if (modifiers.length > 3) return false;
8485 // if expression starts with /, is should be properly terminated
8486 if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
8487 }
8488
8489 return true;
8490}
8491
8492function constructJavascriptRegExp(data) {
8493 var regexp = data,
8494 tail = /\/([gim]*)$/.exec(data),
8495 modifiers = '';
8496
8497 // `/foo/gim` - tail can be maximum 4 chars
8498 if (regexp[0] === '/') {
8499 if (tail) modifiers = tail[1];
8500 regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
8501 }
8502
8503 return new RegExp(regexp, modifiers);
8504}
8505
8506function representJavascriptRegExp(object /*, style*/) {
8507 var result = '/' + object.source + '/';
8508
8509 if (object.global) result += 'g';
8510 if (object.multiline) result += 'm';
8511 if (object.ignoreCase) result += 'i';
8512
8513 return result;
8514}
8515
8516function isRegExp(object) {
8517 return Object.prototype.toString.call(object) === '[object RegExp]';
8518}
8519
8520module.exports = new Type('tag:yaml.org,2002:js/regexp', {
8521 kind: 'scalar',
8522 resolve: resolveJavascriptRegExp,
8523 construct: constructJavascriptRegExp,
8524 predicate: isRegExp,
8525 represent: representJavascriptRegExp
8526});
8527
8528},{"../../type":84}],91:[function(require,module,exports){
8529'use strict';
8530
8531var Type = require('../../type');
8532
8533function resolveJavascriptUndefined() {
8534 return true;
8535}
8536
8537function constructJavascriptUndefined() {
8538 /*eslint-disable no-undefined*/
8539 return undefined;
8540}
8541
8542function representJavascriptUndefined() {
8543 return '';
8544}
8545
8546function isUndefined(object) {
8547 return typeof object === 'undefined';
8548}
8549
8550module.exports = new Type('tag:yaml.org,2002:js/undefined', {
8551 kind: 'scalar',
8552 resolve: resolveJavascriptUndefined,
8553 construct: constructJavascriptUndefined,
8554 predicate: isUndefined,
8555 represent: representJavascriptUndefined
8556});
8557
8558},{"../../type":84}],92:[function(require,module,exports){
8559'use strict';
8560
8561var Type = require('../type');
8562
8563module.exports = new Type('tag:yaml.org,2002:map', {
8564 kind: 'mapping',
8565 construct: function (data) { return data !== null ? data : {}; }
8566});
8567
8568},{"../type":84}],93:[function(require,module,exports){
8569'use strict';
8570
8571var Type = require('../type');
8572
8573function resolveYamlMerge(data) {
8574 return data === '<<' || data === null;
8575}
8576
8577module.exports = new Type('tag:yaml.org,2002:merge', {
8578 kind: 'scalar',
8579 resolve: resolveYamlMerge
8580});
8581
8582},{"../type":84}],94:[function(require,module,exports){
8583'use strict';
8584
8585var Type = require('../type');
8586
8587function resolveYamlNull(data) {
8588 if (data === null) return true;
8589
8590 var max = data.length;
8591
8592 return (max === 1 && data === '~') ||
8593 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
8594}
8595
8596function constructYamlNull() {
8597 return null;
8598}
8599
8600function isNull(object) {
8601 return object === null;
8602}
8603
8604module.exports = new Type('tag:yaml.org,2002:null', {
8605 kind: 'scalar',
8606 resolve: resolveYamlNull,
8607 construct: constructYamlNull,
8608 predicate: isNull,
8609 represent: {
8610 canonical: function () { return '~'; },
8611 lowercase: function () { return 'null'; },
8612 uppercase: function () { return 'NULL'; },
8613 camelcase: function () { return 'Null'; }
8614 },
8615 defaultStyle: 'lowercase'
8616});
8617
8618},{"../type":84}],95:[function(require,module,exports){
8619'use strict';
8620
8621var Type = require('../type');
8622
8623var _hasOwnProperty = Object.prototype.hasOwnProperty;
8624var _toString = Object.prototype.toString;
8625
8626function resolveYamlOmap(data) {
8627 if (data === null) return true;
8628
8629 var objectKeys = [], index, length, pair, pairKey, pairHasKey,
8630 object = data;
8631
8632 for (index = 0, length = object.length; index < length; index += 1) {
8633 pair = object[index];
8634 pairHasKey = false;
8635
8636 if (_toString.call(pair) !== '[object Object]') return false;
8637
8638 for (pairKey in pair) {
8639 if (_hasOwnProperty.call(pair, pairKey)) {
8640 if (!pairHasKey) pairHasKey = true;
8641 else return false;
8642 }
8643 }
8644
8645 if (!pairHasKey) return false;
8646
8647 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
8648 else return false;
8649 }
8650
8651 return true;
8652}
8653
8654function constructYamlOmap(data) {
8655 return data !== null ? data : [];
8656}
8657
8658module.exports = new Type('tag:yaml.org,2002:omap', {
8659 kind: 'sequence',
8660 resolve: resolveYamlOmap,
8661 construct: constructYamlOmap
8662});
8663
8664},{"../type":84}],96:[function(require,module,exports){
8665'use strict';
8666
8667var Type = require('../type');
8668
8669var _toString = Object.prototype.toString;
8670
8671function resolveYamlPairs(data) {
8672 if (data === null) return true;
8673
8674 var index, length, pair, keys, result,
8675 object = data;
8676
8677 result = new Array(object.length);
8678
8679 for (index = 0, length = object.length; index < length; index += 1) {
8680 pair = object[index];
8681
8682 if (_toString.call(pair) !== '[object Object]') return false;
8683
8684 keys = Object.keys(pair);
8685
8686 if (keys.length !== 1) return false;
8687
8688 result[index] = [ keys[0], pair[keys[0]] ];
8689 }
8690
8691 return true;
8692}
8693
8694function constructYamlPairs(data) {
8695 if (data === null) return [];
8696
8697 var index, length, pair, keys, result,
8698 object = data;
8699
8700 result = new Array(object.length);
8701
8702 for (index = 0, length = object.length; index < length; index += 1) {
8703 pair = object[index];
8704
8705 keys = Object.keys(pair);
8706
8707 result[index] = [ keys[0], pair[keys[0]] ];
8708 }
8709
8710 return result;
8711}
8712
8713module.exports = new Type('tag:yaml.org,2002:pairs', {
8714 kind: 'sequence',
8715 resolve: resolveYamlPairs,
8716 construct: constructYamlPairs
8717});
8718
8719},{"../type":84}],97:[function(require,module,exports){
8720'use strict';
8721
8722var Type = require('../type');
8723
8724module.exports = new Type('tag:yaml.org,2002:seq', {
8725 kind: 'sequence',
8726 construct: function (data) { return data !== null ? data : []; }
8727});
8728
8729},{"../type":84}],98:[function(require,module,exports){
8730'use strict';
8731
8732var Type = require('../type');
8733
8734var _hasOwnProperty = Object.prototype.hasOwnProperty;
8735
8736function resolveYamlSet(data) {
8737 if (data === null) return true;
8738
8739 var key, object = data;
8740
8741 for (key in object) {
8742 if (_hasOwnProperty.call(object, key)) {
8743 if (object[key] !== null) return false;
8744 }
8745 }
8746
8747 return true;
8748}
8749
8750function constructYamlSet(data) {
8751 return data !== null ? data : {};
8752}
8753
8754module.exports = new Type('tag:yaml.org,2002:set', {
8755 kind: 'mapping',
8756 resolve: resolveYamlSet,
8757 construct: constructYamlSet
8758});
8759
8760},{"../type":84}],99:[function(require,module,exports){
8761'use strict';
8762
8763var Type = require('../type');
8764
8765module.exports = new Type('tag:yaml.org,2002:str', {
8766 kind: 'scalar',
8767 construct: function (data) { return data !== null ? data : ''; }
8768});
8769
8770},{"../type":84}],100:[function(require,module,exports){
8771'use strict';
8772
8773var Type = require('../type');
8774
8775var YAML_DATE_REGEXP = new RegExp(
8776 '^([0-9][0-9][0-9][0-9])' + // [1] year
8777 '-([0-9][0-9])' + // [2] month
8778 '-([0-9][0-9])$'); // [3] day
8779
8780var YAML_TIMESTAMP_REGEXP = new RegExp(
8781 '^([0-9][0-9][0-9][0-9])' + // [1] year
8782 '-([0-9][0-9]?)' + // [2] month
8783 '-([0-9][0-9]?)' + // [3] day
8784 '(?:[Tt]|[ \\t]+)' + // ...
8785 '([0-9][0-9]?)' + // [4] hour
8786 ':([0-9][0-9])' + // [5] minute
8787 ':([0-9][0-9])' + // [6] second
8788 '(?:\\.([0-9]*))?' + // [7] fraction
8789 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
8790 '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
8791
8792function resolveYamlTimestamp(data) {
8793 if (data === null) return false;
8794 if (YAML_DATE_REGEXP.exec(data) !== null) return true;
8795 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
8796 return false;
8797}
8798
8799function constructYamlTimestamp(data) {
8800 var match, year, month, day, hour, minute, second, fraction = 0,
8801 delta = null, tz_hour, tz_minute, date;
8802
8803 match = YAML_DATE_REGEXP.exec(data);
8804 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
8805
8806 if (match === null) throw new Error('Date resolve error');
8807
8808 // match: [1] year [2] month [3] day
8809
8810 year = +(match[1]);
8811 month = +(match[2]) - 1; // JS month starts with 0
8812 day = +(match[3]);
8813
8814 if (!match[4]) { // no hour
8815 return new Date(Date.UTC(year, month, day));
8816 }
8817
8818 // match: [4] hour [5] minute [6] second [7] fraction
8819
8820 hour = +(match[4]);
8821 minute = +(match[5]);
8822 second = +(match[6]);
8823
8824 if (match[7]) {
8825 fraction = match[7].slice(0, 3);
8826 while (fraction.length < 3) { // milli-seconds
8827 fraction += '0';
8828 }
8829 fraction = +fraction;
8830 }
8831
8832 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
8833
8834 if (match[9]) {
8835 tz_hour = +(match[10]);
8836 tz_minute = +(match[11] || 0);
8837 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
8838 if (match[9] === '-') delta = -delta;
8839 }
8840
8841 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
8842
8843 if (delta) date.setTime(date.getTime() - delta);
8844
8845 return date;
8846}
8847
8848function representYamlTimestamp(object /*, style*/) {
8849 return object.toISOString();
8850}
8851
8852module.exports = new Type('tag:yaml.org,2002:timestamp', {
8853 kind: 'scalar',
8854 resolve: resolveYamlTimestamp,
8855 construct: constructYamlTimestamp,
8856 instanceOf: Date,
8857 represent: representYamlTimestamp
8858});
8859
8860},{"../type":84}],101:[function(require,module,exports){
8861"use strict";
8862
8863var $Ref = require("./ref"),
8864 Pointer = require("./pointer"),
8865 url = require("./util/url");
8866
8867module.exports = bundle;
8868
8869/**
8870 * Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
8871 * only has *internal* references, not any *external* references.
8872 * This method mutates the JSON schema object, adding new references and re-mapping existing ones.
8873 *
8874 * @param {$RefParser} parser
8875 * @param {$RefParserOptions} options
8876 */
8877function bundle (parser, options) {
8878 // console.log('Bundling $ref pointers in %s', parser.$refs._root$Ref.path);
8879
8880 // Build an inventory of all $ref pointers in the JSON Schema
8881 var inventory = [];
8882 crawl(parser, "schema", parser.$refs._root$Ref.path + "#", "#", 0, inventory, parser.$refs, options);
8883
8884 // Remap all $ref pointers
8885 remap(inventory);
8886}
8887
8888/**
8889 * Recursively crawls the given value, and inventories all JSON references.
8890 *
8891 * @param {object} parent - The object containing the value to crawl. If the value is not an object or array, it will be ignored.
8892 * @param {string} key - The property key of `parent` to be crawled
8893 * @param {string} path - The full path of the property being crawled, possibly with a JSON Pointer in the hash
8894 * @param {string} pathFromRoot - The path of the property being crawled, from the schema root
8895 * @param {object[]} inventory - An array of already-inventoried $ref pointers
8896 * @param {$Refs} $refs
8897 * @param {$RefParserOptions} options
8898 */
8899function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs, options) {
8900 var obj = key === null ? parent : parent[key];
8901
8902 if (obj && typeof obj === "object") {
8903 if ($Ref.isAllowed$Ref(obj)) {
8904 inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options);
8905 }
8906 else {
8907 // Crawl the object in a specific order that's optimized for bundling.
8908 // This is important because it determines how `pathFromRoot` gets built,
8909 // which later determines which keys get dereferenced and which ones get remapped
8910 var keys = Object.keys(obj)
8911 .sort(function (a, b) {
8912 // Most people will expect references to be bundled into the the "definitions" property,
8913 // so we always crawl that property first, if it exists.
8914 if (a === "definitions") {
8915 return -1;
8916 }
8917 else if (b === "definitions") {
8918 return 1;
8919 }
8920 else {
8921 // Otherwise, crawl the keys based on their length.
8922 // This produces the shortest possible bundled references
8923 return a.length - b.length;
8924 }
8925 });
8926
8927 keys.forEach(function (key) {
8928 var keyPath = Pointer.join(path, key);
8929 var keyPathFromRoot = Pointer.join(pathFromRoot, key);
8930 var value = obj[key];
8931
8932 if ($Ref.isAllowed$Ref(value)) {
8933 inventory$Ref(obj, key, path, keyPathFromRoot, indirections, inventory, $refs, options);
8934 }
8935 else {
8936 crawl(obj, key, keyPath, keyPathFromRoot, indirections, inventory, $refs, options);
8937 }
8938 });
8939 }
8940 }
8941}
8942
8943/**
8944 * Inventories the given JSON Reference (i.e. records detailed information about it so we can
8945 * optimize all $refs in the schema), and then crawls the resolved value.
8946 *
8947 * @param {object} $refParent - The object that contains a JSON Reference as one of its keys
8948 * @param {string} $refKey - The key in `$refParent` that is a JSON Reference
8949 * @param {string} path - The full path of the JSON Reference at `$refKey`, possibly with a JSON Pointer in the hash
8950 * @param {string} pathFromRoot - The path of the JSON Reference at `$refKey`, from the schema root
8951 * @param {object[]} inventory - An array of already-inventoried $ref pointers
8952 * @param {$Refs} $refs
8953 * @param {$RefParserOptions} options
8954 */
8955function inventory$Ref ($refParent, $refKey, path, pathFromRoot, indirections, inventory, $refs, options) {
8956 var $ref = $refKey === null ? $refParent : $refParent[$refKey];
8957 var $refPath = url.resolve(path, $ref.$ref);
8958 var pointer = $refs._resolve($refPath, options);
8959 var depth = Pointer.parse(pathFromRoot).length;
8960 var file = url.stripHash(pointer.path);
8961 var hash = url.getHash(pointer.path);
8962 var external = file !== $refs._root$Ref.path;
8963 var extended = $Ref.isExtended$Ref($ref);
8964 indirections += pointer.indirections;
8965
8966 var existingEntry = findInInventory(inventory, $refParent, $refKey);
8967 if (existingEntry) {
8968 // This $Ref has already been inventoried, so we don't need to process it again
8969 if (depth < existingEntry.depth || indirections < existingEntry.indirections) {
8970 removeFromInventory(inventory, existingEntry);
8971 }
8972 else {
8973 return;
8974 }
8975 }
8976
8977 inventory.push({
8978 $ref: $ref, // The JSON Reference (e.g. {$ref: string})
8979 parent: $refParent, // The object that contains this $ref pointer
8980 key: $refKey, // The key in `parent` that is the $ref pointer
8981 pathFromRoot: pathFromRoot, // The path to the $ref pointer, from the JSON Schema root
8982 depth: depth, // How far from the JSON Schema root is this $ref pointer?
8983 file: file, // The file that the $ref pointer resolves to
8984 hash: hash, // The hash within `file` that the $ref pointer resolves to
8985 value: pointer.value, // The resolved value of the $ref pointer
8986 circular: pointer.circular, // Is this $ref pointer DIRECTLY circular? (i.e. it references itself)
8987 extended: extended, // Does this $ref extend its resolved value? (i.e. it has extra properties, in addition to "$ref")
8988 external: external, // Does this $ref pointer point to a file other than the main JSON Schema file?
8989 indirections: indirections, // The number of indirect references that were traversed to resolve the value
8990 });
8991
8992 // Recursively crawl the resolved value
8993 crawl(pointer.value, null, pointer.path, pathFromRoot, indirections + 1, inventory, $refs, options);
8994}
8995
8996/**
8997 * Re-maps every $ref pointer, so that they're all relative to the root of the JSON Schema.
8998 * Each referenced value is dereferenced EXACTLY ONCE. All subsequent references to the same
8999 * value are re-mapped to point to the first reference.
9000 *
9001 * @example:
9002 * {
9003 * first: { $ref: somefile.json#/some/part },
9004 * second: { $ref: somefile.json#/another/part },
9005 * third: { $ref: somefile.json },
9006 * fourth: { $ref: somefile.json#/some/part/sub/part }
9007 * }
9008 *
9009 * In this example, there are four references to the same file, but since the third reference points
9010 * to the ENTIRE file, that's the only one we need to dereference. The other three can just be
9011 * remapped to point inside the third one.
9012 *
9013 * On the other hand, if the third reference DIDN'T exist, then the first and second would both need
9014 * to be dereferenced, since they point to different parts of the file. The fourth reference does NOT
9015 * need to be dereferenced, because it can be remapped to point inside the first one.
9016 *
9017 * @param {object[]} inventory
9018 */
9019function remap (inventory) {
9020 // Group & sort all the $ref pointers, so they're in the order that we need to dereference/remap them
9021 inventory.sort(function (a, b) {
9022 if (a.file !== b.file) {
9023 // Group all the $refs that point to the same file
9024 return a.file < b.file ? -1 : +1;
9025 }
9026 else if (a.hash !== b.hash) {
9027 // Group all the $refs that point to the same part of the file
9028 return a.hash < b.hash ? -1 : +1;
9029 }
9030 else if (a.circular !== b.circular) {
9031 // If the $ref points to itself, then sort it higher than other $refs that point to this $ref
9032 return a.circular ? -1 : +1;
9033 }
9034 else if (a.extended !== b.extended) {
9035 // If the $ref extends the resolved value, then sort it lower than other $refs that don't extend the value
9036 return a.extended ? +1 : -1;
9037 }
9038 else if (a.indirections !== b.indirections) {
9039 // Sort direct references higher than indirect references
9040 return a.indirections - b.indirections;
9041 }
9042 else if (a.depth !== b.depth) {
9043 // Sort $refs by how close they are to the JSON Schema root
9044 return a.depth - b.depth;
9045 }
9046 else {
9047 // Determine how far each $ref is from the "definitions" property.
9048 // Most people will expect references to be bundled into the the "definitions" property if possible.
9049 var aDefinitionsIndex = a.pathFromRoot.lastIndexOf("/definitions");
9050 var bDefinitionsIndex = b.pathFromRoot.lastIndexOf("/definitions");
9051
9052 if (aDefinitionsIndex !== bDefinitionsIndex) {
9053 // Give higher priority to the $ref that's closer to the "definitions" property
9054 return bDefinitionsIndex - aDefinitionsIndex;
9055 }
9056 else {
9057 // All else is equal, so use the shorter path, which will produce the shortest possible reference
9058 return a.pathFromRoot.length - b.pathFromRoot.length;
9059 }
9060 }
9061 });
9062
9063 var file, hash, pathFromRoot;
9064 inventory.forEach(function (entry) {
9065 // console.log('Re-mapping $ref pointer "%s" at %s', entry.$ref.$ref, entry.pathFromRoot);
9066
9067 if (!entry.external) {
9068 // This $ref already resolves to the main JSON Schema file
9069 entry.$ref.$ref = entry.hash;
9070 }
9071 else if (entry.file === file && entry.hash === hash) {
9072 // This $ref points to the same value as the prevous $ref, so remap it to the same path
9073 entry.$ref.$ref = pathFromRoot;
9074 }
9075 else if (entry.file === file && entry.hash.indexOf(hash + "/") === 0) {
9076 // This $ref points to a sub-value of the prevous $ref, so remap it beneath that path
9077 entry.$ref.$ref = Pointer.join(pathFromRoot, Pointer.parse(entry.hash.replace(hash, "#")));
9078 }
9079 else {
9080 // We've moved to a new file or new hash
9081 file = entry.file;
9082 hash = entry.hash;
9083 pathFromRoot = entry.pathFromRoot;
9084
9085 // This is the first $ref to point to this value, so dereference the value.
9086 // Any other $refs that point to the same value will point to this $ref instead
9087 entry.$ref = entry.parent[entry.key] = $Ref.dereference(entry.$ref, entry.value);
9088
9089 if (entry.circular) {
9090 // This $ref points to itself
9091 entry.$ref.$ref = entry.pathFromRoot;
9092 }
9093 }
9094
9095 // console.log(' new value: %s', (entry.$ref && entry.$ref.$ref) ? entry.$ref.$ref : '[object Object]');
9096 });
9097}
9098
9099/**
9100 * TODO
9101 */
9102function findInInventory (inventory, $refParent, $refKey) {
9103 for (var i = 0; i < inventory.length; i++) {
9104 var existingEntry = inventory[i];
9105 if (existingEntry.parent === $refParent && existingEntry.key === $refKey) {
9106 return existingEntry;
9107 }
9108 }
9109}
9110
9111function removeFromInventory (inventory, entry) {
9112 var index = inventory.indexOf(entry);
9113 inventory.splice(index, 1);
9114}
9115
9116},{"./pointer":111,"./ref":112,"./util/url":118}],102:[function(require,module,exports){
9117"use strict";
9118
9119var $Ref = require("./ref"),
9120 Pointer = require("./pointer"),
9121 ono = require("ono"),
9122 url = require("./util/url");
9123
9124module.exports = dereference;
9125
9126/**
9127 * Crawls the JSON schema, finds all JSON references, and dereferences them.
9128 * This method mutates the JSON schema object, replacing JSON references with their resolved value.
9129 *
9130 * @param {$RefParser} parser
9131 * @param {$RefParserOptions} options
9132 */
9133function dereference (parser, options) {
9134 // console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path);
9135 var dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, "#", [], parser.$refs, options);
9136 parser.$refs.circular = dereferenced.circular;
9137 parser.schema = dereferenced.value;
9138}
9139
9140/**
9141 * Recursively crawls the given value, and dereferences any JSON references.
9142 *
9143 * @param {*} obj - The value to crawl. If it's not an object or array, it will be ignored.
9144 * @param {string} path - The full path of `obj`, possibly with a JSON Pointer in the hash
9145 * @param {string} pathFromRoot - The path of `obj` from the schema root
9146 * @param {object[]} parents - An array of the parent objects that have already been dereferenced
9147 * @param {$Refs} $refs
9148 * @param {$RefParserOptions} options
9149 * @returns {{value: object, circular: boolean}}
9150 */
9151function crawl (obj, path, pathFromRoot, parents, $refs, options) {
9152 var dereferenced;
9153 var result = {
9154 value: obj,
9155 circular: false
9156 };
9157
9158 if (obj && typeof obj === "object") {
9159 parents.push(obj);
9160
9161 if ($Ref.isAllowed$Ref(obj, options)) {
9162 dereferenced = dereference$Ref(obj, path, pathFromRoot, parents, $refs, options);
9163 result.circular = dereferenced.circular;
9164 result.value = dereferenced.value;
9165 }
9166 else {
9167 Object.keys(obj).forEach(function (key) {
9168 var keyPath = Pointer.join(path, key);
9169 var keyPathFromRoot = Pointer.join(pathFromRoot, key);
9170 var value = obj[key];
9171 var circular = false;
9172
9173 if ($Ref.isAllowed$Ref(value, options)) {
9174 dereferenced = dereference$Ref(value, keyPath, keyPathFromRoot, parents, $refs, options);
9175 circular = dereferenced.circular;
9176 obj[key] = dereferenced.value;
9177 }
9178 else {
9179 if (parents.indexOf(value) === -1) {
9180 dereferenced = crawl(value, keyPath, keyPathFromRoot, parents, $refs, options);
9181 circular = dereferenced.circular;
9182 obj[key] = dereferenced.value;
9183 }
9184 else {
9185 circular = foundCircularReference(keyPath, $refs, options);
9186 }
9187 }
9188
9189 // Set the "isCircular" flag if this or any other property is circular
9190 result.circular = result.circular || circular;
9191 });
9192 }
9193
9194 parents.pop();
9195 }
9196
9197 return result;
9198}
9199
9200/**
9201 * Dereferences the given JSON Reference, and then crawls the resulting value.
9202 *
9203 * @param {{$ref: string}} $ref - The JSON Reference to resolve
9204 * @param {string} path - The full path of `$ref`, possibly with a JSON Pointer in the hash
9205 * @param {string} pathFromRoot - The path of `$ref` from the schema root
9206 * @param {object[]} parents - An array of the parent objects that have already been dereferenced
9207 * @param {$Refs} $refs
9208 * @param {$RefParserOptions} options
9209 * @returns {{value: object, circular: boolean}}
9210 */
9211function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
9212 // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);
9213
9214 var $refPath = url.resolve(path, $ref.$ref);
9215 var pointer = $refs._resolve($refPath, options);
9216
9217 // Check for circular references
9218 var directCircular = pointer.circular;
9219 var circular = directCircular || parents.indexOf(pointer.value) !== -1;
9220 circular && foundCircularReference(path, $refs, options);
9221
9222 // Dereference the JSON reference
9223 var dereferencedValue = $Ref.dereference($ref, pointer.value);
9224
9225 // Crawl the dereferenced value (unless it's circular)
9226 if (!circular) {
9227 // Determine if the dereferenced value is circular
9228 var dereferenced = crawl(dereferencedValue, pointer.path, pathFromRoot, parents, $refs, options);
9229 circular = dereferenced.circular;
9230 dereferencedValue = dereferenced.value;
9231 }
9232
9233 if (circular && !directCircular && options.dereference.circular === "ignore") {
9234 // The user has chosen to "ignore" circular references, so don't change the value
9235 dereferencedValue = $ref;
9236 }
9237
9238 if (directCircular) {
9239 // The pointer is a DIRECT circular reference (i.e. it references itself).
9240 // So replace the $ref path with the absolute path from the JSON Schema root
9241 dereferencedValue.$ref = pathFromRoot;
9242 }
9243
9244 return {
9245 circular: circular,
9246 value: dereferencedValue
9247 };
9248}
9249
9250/**
9251 * Called when a circular reference is found.
9252 * It sets the {@link $Refs#circular} flag, and throws an error if options.dereference.circular is false.
9253 *
9254 * @param {string} keyPath - The JSON Reference path of the circular reference
9255 * @param {$Refs} $refs
9256 * @param {$RefParserOptions} options
9257 * @returns {boolean} - always returns true, to indicate that a circular reference was found
9258 */
9259function foundCircularReference (keyPath, $refs, options) {
9260 $refs.circular = true;
9261 if (!options.dereference.circular) {
9262 throw ono.reference("Circular $ref pointer found at %s", keyPath);
9263 }
9264 return true;
9265}
9266
9267},{"./pointer":111,"./ref":112,"./util/url":118,"ono":122}],103:[function(require,module,exports){
9268(function (Buffer){
9269"use strict";
9270
9271var Options = require("./options"),
9272 $Refs = require("./refs"),
9273 parse = require("./parse"),
9274 normalizeArgs = require("./normalize-args"),
9275 resolveExternal = require("./resolve-external"),
9276 bundle = require("./bundle"),
9277 dereference = require("./dereference"),
9278 url = require("./util/url"),
9279 maybe = require("call-me-maybe"),
9280 ono = require("ono");
9281
9282module.exports = $RefParser;
9283module.exports.YAML = require("./util/yaml");
9284
9285/**
9286 * This class parses a JSON schema, builds a map of its JSON references and their resolved values,
9287 * and provides methods for traversing, manipulating, and dereferencing those references.
9288 *
9289 * @constructor
9290 */
9291function $RefParser () {
9292 /**
9293 * The parsed (and possibly dereferenced) JSON schema object
9294 *
9295 * @type {object}
9296 * @readonly
9297 */
9298 this.schema = null;
9299
9300 /**
9301 * The resolved JSON references
9302 *
9303 * @type {$Refs}
9304 * @readonly
9305 */
9306 this.$refs = new $Refs();
9307}
9308
9309/**
9310 * Parses the given JSON schema.
9311 * This method does not resolve any JSON references.
9312 * It just reads a single file in JSON or YAML format, and parse it as a JavaScript object.
9313 *
9314 * @param {string} [path] - The file path or URL of the JSON schema
9315 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9316 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed
9317 * @param {function} [callback] - An error-first callback. The second parameter is the parsed JSON schema object.
9318 * @returns {Promise} - The returned promise resolves with the parsed JSON schema object.
9319 */
9320$RefParser.parse = function (path, schema, options, callback) {
9321 var Class = this; // eslint-disable-line consistent-this
9322 var instance = new Class();
9323 return instance.parse.apply(instance, arguments);
9324};
9325
9326/**
9327 * Parses the given JSON schema.
9328 * This method does not resolve any JSON references.
9329 * It just reads a single file in JSON or YAML format, and parse it as a JavaScript object.
9330 *
9331 * @param {string} [path] - The file path or URL of the JSON schema
9332 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9333 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed
9334 * @param {function} [callback] - An error-first callback. The second parameter is the parsed JSON schema object.
9335 * @returns {Promise} - The returned promise resolves with the parsed JSON schema object.
9336 */
9337$RefParser.prototype.parse = function (path, schema, options, callback) {
9338 var args = normalizeArgs(arguments);
9339 var promise;
9340
9341 if (!args.path && !args.schema) {
9342 var err = ono("Expected a file path, URL, or object. Got %s", args.path || args.schema);
9343 return maybe(args.callback, Promise.reject(err));
9344 }
9345
9346 // Reset everything
9347 this.schema = null;
9348 this.$refs = new $Refs();
9349
9350 // If the path is a filesystem path, then convert it to a URL.
9351 // NOTE: According to the JSON Reference spec, these should already be URLs,
9352 // but, in practice, many people use local filesystem paths instead.
9353 // So we're being generous here and doing the conversion automatically.
9354 // This is not intended to be a 100% bulletproof solution.
9355 // If it doesn't work for your use-case, then use a URL instead.
9356 var pathType = "http";
9357 if (url.isFileSystemPath(args.path)) {
9358 args.path = url.fromFileSystemPath(args.path);
9359 pathType = "file";
9360 }
9361
9362 // Resolve the absolute path of the schema
9363 args.path = url.resolve(url.cwd(), args.path);
9364
9365 if (args.schema && typeof args.schema === "object") {
9366 // A schema object was passed-in.
9367 // So immediately add a new $Ref with the schema object as its value
9368 var $ref = this.$refs._add(args.path);
9369 $ref.value = args.schema;
9370 $ref.pathType = pathType;
9371 promise = Promise.resolve(args.schema);
9372 }
9373 else {
9374 // Parse the schema file/url
9375 promise = parse(args.path, this.$refs, args.options);
9376 }
9377
9378 var me = this;
9379 return promise
9380 .then(function (result) {
9381 if (!result || typeof result !== "object" || Buffer.isBuffer(result)) {
9382 throw ono.syntax('"%s" is not a valid JSON Schema', me.$refs._root$Ref.path || result);
9383 }
9384 else {
9385 me.schema = result;
9386 return maybe(args.callback, Promise.resolve(me.schema));
9387 }
9388 })
9389 .catch(function (e) {
9390 return maybe(args.callback, Promise.reject(e));
9391 });
9392};
9393
9394/**
9395 * Parses the given JSON schema and resolves any JSON references, including references in
9396 * externally-referenced files.
9397 *
9398 * @param {string} [path] - The file path or URL of the JSON schema
9399 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9400 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed and resolved
9401 * @param {function} [callback]
9402 * - An error-first callback. The second parameter is a {@link $Refs} object containing the resolved JSON references
9403 *
9404 * @returns {Promise}
9405 * The returned promise resolves with a {@link $Refs} object containing the resolved JSON references
9406 */
9407$RefParser.resolve = function (path, schema, options, callback) {
9408 var Class = this; // eslint-disable-line consistent-this
9409 var instance = new Class();
9410 return instance.resolve.apply(instance, arguments);
9411};
9412
9413/**
9414 * Parses the given JSON schema and resolves any JSON references, including references in
9415 * externally-referenced files.
9416 *
9417 * @param {string} [path] - The file path or URL of the JSON schema
9418 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9419 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed and resolved
9420 * @param {function} [callback]
9421 * - An error-first callback. The second parameter is a {@link $Refs} object containing the resolved JSON references
9422 *
9423 * @returns {Promise}
9424 * The returned promise resolves with a {@link $Refs} object containing the resolved JSON references
9425 */
9426$RefParser.prototype.resolve = function (path, schema, options, callback) {
9427 var me = this;
9428 var args = normalizeArgs(arguments);
9429
9430 return this.parse(args.path, args.schema, args.options)
9431 .then(function () {
9432 return resolveExternal(me, args.options);
9433 })
9434 .then(function () {
9435 return maybe(args.callback, Promise.resolve(me.$refs));
9436 })
9437 .catch(function (err) {
9438 return maybe(args.callback, Promise.reject(err));
9439 });
9440};
9441
9442/**
9443 * Parses the given JSON schema, resolves any JSON references, and bundles all external references
9444 * into the main JSON schema. This produces a JSON schema that only has *internal* references,
9445 * not any *external* references.
9446 *
9447 * @param {string} [path] - The file path or URL of the JSON schema
9448 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9449 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed, resolved, and dereferenced
9450 * @param {function} [callback] - An error-first callback. The second parameter is the bundled JSON schema object
9451 * @returns {Promise} - The returned promise resolves with the bundled JSON schema object.
9452 */
9453$RefParser.bundle = function (path, schema, options, callback) {
9454 var Class = this; // eslint-disable-line consistent-this
9455 var instance = new Class();
9456 return instance.bundle.apply(instance, arguments);
9457};
9458
9459/**
9460 * Parses the given JSON schema, resolves any JSON references, and bundles all external references
9461 * into the main JSON schema. This produces a JSON schema that only has *internal* references,
9462 * not any *external* references.
9463 *
9464 * @param {string} [path] - The file path or URL of the JSON schema
9465 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9466 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed, resolved, and dereferenced
9467 * @param {function} [callback] - An error-first callback. The second parameter is the bundled JSON schema object
9468 * @returns {Promise} - The returned promise resolves with the bundled JSON schema object.
9469 */
9470$RefParser.prototype.bundle = function (path, schema, options, callback) {
9471 var me = this;
9472 var args = normalizeArgs(arguments);
9473
9474 return this.resolve(args.path, args.schema, args.options)
9475 .then(function () {
9476 bundle(me, args.options);
9477 return maybe(args.callback, Promise.resolve(me.schema));
9478 })
9479 .catch(function (err) {
9480 return maybe(args.callback, Promise.reject(err));
9481 });
9482};
9483
9484/**
9485 * Parses the given JSON schema, resolves any JSON references, and dereferences the JSON schema.
9486 * That is, all JSON references are replaced with their resolved values.
9487 *
9488 * @param {string} [path] - The file path or URL of the JSON schema
9489 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9490 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed, resolved, and dereferenced
9491 * @param {function} [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
9492 * @returns {Promise} - The returned promise resolves with the dereferenced JSON schema object.
9493 */
9494$RefParser.dereference = function (path, schema, options, callback) {
9495 var Class = this; // eslint-disable-line consistent-this
9496 var instance = new Class();
9497 return instance.dereference.apply(instance, arguments);
9498};
9499
9500/**
9501 * Parses the given JSON schema, resolves any JSON references, and dereferences the JSON schema.
9502 * That is, all JSON references are replaced with their resolved values.
9503 *
9504 * @param {string} [path] - The file path or URL of the JSON schema
9505 * @param {object} [schema] - A JSON schema object. This object will be used instead of reading from `path`.
9506 * @param {$RefParserOptions} [options] - Options that determine how the schema is parsed, resolved, and dereferenced
9507 * @param {function} [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
9508 * @returns {Promise} - The returned promise resolves with the dereferenced JSON schema object.
9509 */
9510$RefParser.prototype.dereference = function (path, schema, options, callback) {
9511 var me = this;
9512 var args = normalizeArgs(arguments);
9513
9514 return this.resolve(args.path, args.schema, args.options)
9515 .then(function () {
9516 dereference(me, args.options);
9517 return maybe(args.callback, Promise.resolve(me.schema));
9518 })
9519 .catch(function (err) {
9520 return maybe(args.callback, Promise.reject(err));
9521 });
9522};
9523
9524}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
9525
9526},{"../../is-buffer/index.js":69,"./bundle":101,"./dereference":102,"./normalize-args":104,"./options":105,"./parse":106,"./refs":113,"./resolve-external":114,"./util/url":118,"./util/yaml":119,"call-me-maybe":11,"ono":122}],104:[function(require,module,exports){
9527"use strict";
9528
9529var Options = require("./options");
9530
9531module.exports = normalizeArgs;
9532
9533/**
9534 * Normalizes the given arguments, accounting for optional args.
9535 *
9536 * @param {Arguments} args
9537 * @returns {object}
9538 */
9539function normalizeArgs (args) {
9540 var path, schema, options, callback;
9541 args = Array.prototype.slice.call(args);
9542
9543 if (typeof args[args.length - 1] === "function") {
9544 // The last parameter is a callback function
9545 callback = args.pop();
9546 }
9547
9548 if (typeof args[0] === "string") {
9549 // The first parameter is the path
9550 path = args[0];
9551 if (typeof args[2] === "object") {
9552 // The second parameter is the schema, and the third parameter is the options
9553 schema = args[1];
9554 options = args[2];
9555 }
9556 else {
9557 // The second parameter is the options
9558 schema = undefined;
9559 options = args[1];
9560 }
9561 }
9562 else {
9563 // The first parameter is the schema
9564 path = "";
9565 schema = args[0];
9566 options = args[1];
9567 }
9568
9569 if (!(options instanceof Options)) {
9570 options = new Options(options);
9571 }
9572
9573 return {
9574 path: path,
9575 schema: schema,
9576 options: options,
9577 callback: callback
9578 };
9579}
9580
9581},{"./options":105}],105:[function(require,module,exports){
9582/* eslint lines-around-comment: [2, {beforeBlockComment: false}] */
9583"use strict";
9584
9585var jsonParser = require("./parsers/json"),
9586 yamlParser = require("./parsers/yaml"),
9587 textParser = require("./parsers/text"),
9588 binaryParser = require("./parsers/binary"),
9589 fileResolver = require("./resolvers/file"),
9590 httpResolver = require("./resolvers/http");
9591
9592module.exports = $RefParserOptions;
9593
9594/**
9595 * Options that determine how JSON schemas are parsed, resolved, and dereferenced.
9596 *
9597 * @param {object|$RefParserOptions} [options] - Overridden options
9598 * @constructor
9599 */
9600function $RefParserOptions (options) {
9601 merge(this, $RefParserOptions.defaults);
9602 merge(this, options);
9603}
9604
9605$RefParserOptions.defaults = {
9606 /**
9607 * Determines how different types of files will be parsed.
9608 *
9609 * You can add additional parsers of your own, replace an existing one with
9610 * your own implemenation, or disable any parser by setting it to false.
9611 */
9612 parse: {
9613 json: jsonParser,
9614 yaml: yamlParser,
9615 text: textParser,
9616 binary: binaryParser,
9617 },
9618
9619 /**
9620 * Determines how JSON References will be resolved.
9621 *
9622 * You can add additional resolvers of your own, replace an existing one with
9623 * your own implemenation, or disable any resolver by setting it to false.
9624 */
9625 resolve: {
9626 file: fileResolver,
9627 http: httpResolver,
9628
9629 /**
9630 * Determines whether external $ref pointers will be resolved.
9631 * If this option is disabled, then none of above resolvers will be called.
9632 * Instead, external $ref pointers will simply be ignored.
9633 *
9634 * @type {boolean}
9635 */
9636 external: true,
9637 },
9638
9639 /**
9640 * Determines the types of JSON references that are allowed.
9641 */
9642 dereference: {
9643 /**
9644 * Dereference circular (recursive) JSON references?
9645 * If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
9646 * If "ignore", then circular references will not be dereferenced.
9647 *
9648 * @type {boolean|string}
9649 */
9650 circular: true
9651 },
9652};
9653
9654/**
9655 * Merges the properties of the source object into the target object.
9656 *
9657 * @param {object} target - The object that we're populating
9658 * @param {?object} source - The options that are being merged
9659 * @returns {object}
9660 */
9661function merge (target, source) {
9662 if (isMergeable(source)) {
9663 var keys = Object.keys(source);
9664 for (var i = 0; i < keys.length; i++) {
9665 var key = keys[i];
9666 var sourceSetting = source[key];
9667 var targetSetting = target[key];
9668
9669 if (isMergeable(sourceSetting)) {
9670 // It's a nested object, so merge it recursively
9671 target[key] = merge(targetSetting || {}, sourceSetting);
9672 }
9673 else if (sourceSetting !== undefined) {
9674 // It's a scalar value, function, or array. No merging necessary. Just overwrite the target value.
9675 target[key] = sourceSetting;
9676 }
9677 }
9678 }
9679 return target;
9680}
9681
9682/**
9683 * Determines whether the given value can be merged,
9684 * or if it is a scalar value that should just override the target value.
9685 *
9686 * @param {*} val
9687 * @returns {Boolean}
9688 */
9689function isMergeable (val) {
9690 return val &&
9691 (typeof val === "object") &&
9692 !Array.isArray(val) &&
9693 !(val instanceof RegExp) &&
9694 !(val instanceof Date);
9695}
9696
9697},{"./parsers/binary":107,"./parsers/json":108,"./parsers/text":109,"./parsers/yaml":110,"./resolvers/file":115,"./resolvers/http":116}],106:[function(require,module,exports){
9698(function (Buffer){
9699"use strict";
9700
9701var ono = require("ono"),
9702 url = require("./util/url"),
9703 plugins = require("./util/plugins");
9704
9705module.exports = parse;
9706
9707/**
9708 * Reads and parses the specified file path or URL.
9709 *
9710 * @param {string} path - This path MUST already be resolved, since `read` doesn't know the resolution context
9711 * @param {$Refs} $refs
9712 * @param {$RefParserOptions} options
9713 *
9714 * @returns {Promise}
9715 * The promise resolves with the parsed file contents, NOT the raw (Buffer) contents.
9716 */
9717function parse (path, $refs, options) {
9718 try {
9719 // Remove the URL fragment, if any
9720 path = url.stripHash(path);
9721
9722 // Add a new $Ref for this file, even though we don't have the value yet.
9723 // This ensures that we don't simultaneously read & parse the same file multiple times
9724 var $ref = $refs._add(path);
9725
9726 // This "file object" will be passed to all resolvers and parsers.
9727 var file = {
9728 url: path,
9729 extension: url.getExtension(path),
9730 };
9731
9732 // Read the file and then parse the data
9733 return readFile(file, options)
9734 .then(function (resolver) {
9735 $ref.pathType = resolver.plugin.name;
9736 file.data = resolver.result;
9737 return parseFile(file, options);
9738 })
9739 .then(function (parser) {
9740 $ref.value = parser.result;
9741 return parser.result;
9742 });
9743 }
9744 catch (e) {
9745 return Promise.reject(e);
9746 }
9747}
9748
9749/**
9750 * Reads the given file, using the configured resolver plugins
9751 *
9752 * @param {object} file - An object containing information about the referenced file
9753 * @param {string} file.url - The full URL of the referenced file
9754 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
9755 * @param {$RefParserOptions} options
9756 *
9757 * @returns {Promise}
9758 * The promise resolves with the raw file contents and the resolver that was used.
9759 */
9760function readFile (file, options) {
9761 return new Promise(function (resolve, reject) {
9762 // console.log('Reading %s', file.url);
9763
9764 // Find the resolvers that can read this file
9765 var resolvers = plugins.all(options.resolve);
9766 resolvers = plugins.filter(resolvers, "canRead", file);
9767
9768 // Run the resolvers, in order, until one of them succeeds
9769 plugins.sort(resolvers);
9770 plugins.run(resolvers, "read", file)
9771 .then(resolve, onError);
9772
9773 function onError (err) {
9774 // Throw the original error, if it's one of our own (user-friendly) errors.
9775 // Otherwise, throw a generic, friendly error.
9776 if (err && !(err instanceof SyntaxError)) {
9777 reject(err);
9778 }
9779 else {
9780 reject(ono.syntax('Unable to resolve $ref pointer "%s"', file.url));
9781 }
9782 }
9783 });
9784}
9785
9786/**
9787 * Parses the given file's contents, using the configured parser plugins.
9788 *
9789 * @param {object} file - An object containing information about the referenced file
9790 * @param {string} file.url - The full URL of the referenced file
9791 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
9792 * @param {*} file.data - The file contents. This will be whatever data type was returned by the resolver
9793 * @param {$RefParserOptions} options
9794 *
9795 * @returns {Promise}
9796 * The promise resolves with the parsed file contents and the parser that was used.
9797 */
9798function parseFile (file, options) {
9799 return new Promise(function (resolve, reject) {
9800 // console.log('Parsing %s', file.url);
9801
9802 // Find the parsers that can read this file type.
9803 // If none of the parsers are an exact match for this file, then we'll try ALL of them.
9804 // This handles situations where the file IS a supported type, just with an unknown extension.
9805 var allParsers = plugins.all(options.parse);
9806 var filteredParsers = plugins.filter(allParsers, "canParse", file);
9807 var parsers = filteredParsers.length > 0 ? filteredParsers : allParsers;
9808
9809 // Run the parsers, in order, until one of them succeeds
9810 plugins.sort(parsers);
9811 plugins.run(parsers, "parse", file)
9812 .then(onParsed, onError);
9813
9814 function onParsed (parser) {
9815 if (!parser.plugin.allowEmpty && isEmpty(parser.result)) {
9816 reject(ono.syntax('Error parsing "%s" as %s. \nParsed value is empty', file.url, parser.plugin.name));
9817 }
9818 else {
9819 resolve(parser);
9820 }
9821 }
9822
9823 function onError (err) {
9824 if (err) {
9825 err = err instanceof Error ? err : new Error(err);
9826 reject(ono.syntax(err, "Error parsing %s", file.url));
9827 }
9828 else {
9829 reject(ono.syntax("Unable to parse %s", file.url));
9830 }
9831 }
9832 });
9833}
9834
9835/**
9836 * Determines whether the parsed value is "empty".
9837 *
9838 * @param {*} value
9839 * @returns {boolean}
9840 */
9841function isEmpty (value) {
9842 return value === undefined ||
9843 (typeof value === "object" && Object.keys(value).length === 0) ||
9844 (typeof value === "string" && value.trim().length === 0) ||
9845 (Buffer.isBuffer(value) && value.length === 0);
9846}
9847
9848}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
9849
9850},{"../../is-buffer/index.js":69,"./util/plugins":117,"./util/url":118,"ono":122}],107:[function(require,module,exports){
9851(function (Buffer){
9852"use strict";
9853
9854var BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
9855
9856module.exports = {
9857 /**
9858 * The order that this parser will run, in relation to other parsers.
9859 *
9860 * @type {number}
9861 */
9862 order: 400,
9863
9864 /**
9865 * Whether to allow "empty" files (zero bytes).
9866 *
9867 * @type {boolean}
9868 */
9869 allowEmpty: true,
9870
9871 /**
9872 * Determines whether this parser can parse a given file reference.
9873 * Parsers that return true will be tried, in order, until one successfully parses the file.
9874 * Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
9875 * every parser will be tried.
9876 *
9877 * @param {object} file - An object containing information about the referenced file
9878 * @param {string} file.url - The full URL of the referenced file
9879 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
9880 * @param {*} file.data - The file contents. This will be whatever data type was returned by the resolver
9881 * @returns {boolean}
9882 */
9883 canParse: function isBinary (file) {
9884 // Use this parser if the file is a Buffer, and has a known binary extension
9885 return Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url);
9886 },
9887
9888 /**
9889 * Parses the given data as a Buffer (byte array).
9890 *
9891 * @param {object} file - An object containing information about the referenced file
9892 * @param {string} file.url - The full URL of the referenced file
9893 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
9894 * @param {*} file.data - The file contents. This will be whatever data type was returned by the resolver
9895 * @returns {Promise<Buffer>}
9896 */
9897 parse: function parseBinary (file) {
9898 if (Buffer.isBuffer(file.data)) {
9899 return file.data;
9900 }
9901 else {
9902 // This will reject if data is anything other than a string or typed array
9903 return new Buffer(file.data);
9904 }
9905 }
9906};
9907
9908}).call(this,require("buffer").Buffer)
9909
9910},{"buffer":9}],108:[function(require,module,exports){
9911(function (Buffer){
9912"use strict";
9913
9914module.exports = {
9915 /**
9916 * The order that this parser will run, in relation to other parsers.
9917 *
9918 * @type {number}
9919 */
9920 order: 100,
9921
9922 /**
9923 * Whether to allow "empty" files. This includes zero-byte files, as well as empty JSON objects.
9924 *
9925 * @type {boolean}
9926 */
9927 allowEmpty: true,
9928
9929 /**
9930 * Determines whether this parser can parse a given file reference.
9931 * Parsers that match will be tried, in order, until one successfully parses the file.
9932 * Parsers that don't match will be skipped, UNLESS none of the parsers match, in which case
9933 * every parser will be tried.
9934 *
9935 * @type {RegExp|string[]|function}
9936 */
9937 canParse: ".json",
9938
9939 /**
9940 * Parses the given file as JSON
9941 *
9942 * @param {object} file - An object containing information about the referenced file
9943 * @param {string} file.url - The full URL of the referenced file
9944 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
9945 * @param {*} file.data - The file contents. This will be whatever data type was returned by the resolver
9946 * @returns {Promise}
9947 */
9948 parse: function parseJSON (file) {
9949 return new Promise(function (resolve, reject) {
9950 var data = file.data;
9951 if (Buffer.isBuffer(data)) {
9952 data = data.toString();
9953 }
9954
9955 if (typeof data === "string") {
9956 if (data.trim().length === 0) {
9957 resolve(undefined); // This mirrors the YAML behavior
9958 }
9959 else {
9960 resolve(JSON.parse(data));
9961 }
9962 }
9963 else {
9964 // data is already a JavaScript value (object, array, number, null, NaN, etc.)
9965 resolve(data);
9966 }
9967 });
9968 }
9969};
9970
9971}).call(this,{"isBuffer":require("../../../is-buffer/index.js")})
9972
9973},{"../../../is-buffer/index.js":69}],109:[function(require,module,exports){
9974(function (Buffer){
9975"use strict";
9976
9977var TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
9978
9979module.exports = {
9980 /**
9981 * The order that this parser will run, in relation to other parsers.
9982 *
9983 * @type {number}
9984 */
9985 order: 300,
9986
9987 /**
9988 * Whether to allow "empty" files (zero bytes).
9989 *
9990 * @type {boolean}
9991 */
9992 allowEmpty: true,
9993
9994 /**
9995 * The encoding that the text is expected to be in.
9996 *
9997 * @type {string}
9998 */
9999 encoding: "utf8",
10000
10001 /**
10002 * Determines whether this parser can parse a given file reference.
10003 * Parsers that return true will be tried, in order, until one successfully parses the file.
10004 * Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
10005 * every parser will be tried.
10006 *
10007 * @param {object} file - An object containing information about the referenced file
10008 * @param {string} file.url - The full URL of the referenced file
10009 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
10010 * @param {*} file.data - The file contents. This will be whatever data type was returned by the resolver
10011 * @returns {boolean}
10012 */
10013 canParse: function isText (file) {
10014 // Use this parser if the file is a string or Buffer, and has a known text-based extension
10015 return (typeof file.data === "string" || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url);
10016 },
10017
10018 /**
10019 * Parses the given file as text
10020 *
10021 * @param {object} file - An object containing information about the referenced file
10022 * @param {string} file.url - The full URL of the referenced file
10023 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
10024 * @param {*} file.data - The file contents. This will be whatever data type was returned by the resolver
10025 * @returns {Promise<string>}
10026 */
10027 parse: function parseText (file) {
10028 if (typeof file.data === "string") {
10029 return file.data;
10030 }
10031 else if (Buffer.isBuffer(file.data)) {
10032 return file.data.toString(this.encoding);
10033 }
10034 else {
10035 throw new Error("data is not text");
10036 }
10037 }
10038};
10039
10040}).call(this,{"isBuffer":require("../../../is-buffer/index.js")})
10041
10042},{"../../../is-buffer/index.js":69}],110:[function(require,module,exports){
10043(function (Buffer){
10044"use strict";
10045
10046var YAML = require("../util/yaml");
10047
10048module.exports = {
10049 /**
10050 * The order that this parser will run, in relation to other parsers.
10051 *
10052 * @type {number}
10053 */
10054 order: 200,
10055
10056 /**
10057 * Whether to allow "empty" files. This includes zero-byte files, as well as empty JSON objects.
10058 *
10059 * @type {boolean}
10060 */
10061 allowEmpty: true,
10062
10063 /**
10064 * Determines whether this parser can parse a given file reference.
10065 * Parsers that match will be tried, in order, until one successfully parses the file.
10066 * Parsers that don't match will be skipped, UNLESS none of the parsers match, in which case
10067 * every parser will be tried.
10068 *
10069 * @type {RegExp|string[]|function}
10070 */
10071 canParse: [".yaml", ".yml", ".json"], // JSON is valid YAML
10072
10073 /**
10074 * Parses the given file as YAML
10075 *
10076 * @param {object} file - An object containing information about the referenced file
10077 * @param {string} file.url - The full URL of the referenced file
10078 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
10079 * @param {*} file.data - The file contents. This will be whatever data type was returned by the resolver
10080 * @returns {Promise}
10081 */
10082 parse: function parseYAML (file) {
10083 return new Promise(function (resolve, reject) {
10084 var data = file.data;
10085 if (Buffer.isBuffer(data)) {
10086 data = data.toString();
10087 }
10088
10089 if (typeof data === "string") {
10090 resolve(YAML.parse(data));
10091 }
10092 else {
10093 // data is already a JavaScript value (object, array, number, null, NaN, etc.)
10094 resolve(data);
10095 }
10096 });
10097 }
10098};
10099
10100}).call(this,{"isBuffer":require("../../../is-buffer/index.js")})
10101
10102},{"../../../is-buffer/index.js":69,"../util/yaml":119}],111:[function(require,module,exports){
10103"use strict";
10104
10105module.exports = Pointer;
10106
10107var $Ref = require("./ref"),
10108 url = require("./util/url"),
10109 ono = require("ono"),
10110 slashes = /\//g,
10111 tildes = /~/g,
10112 escapedSlash = /~1/g,
10113 escapedTilde = /~0/g;
10114
10115/**
10116 * This class represents a single JSON pointer and its resolved value.
10117 *
10118 * @param {$Ref} $ref
10119 * @param {string} path
10120 * @param {string} [friendlyPath] - The original user-specified path (used for error messages)
10121 * @constructor
10122 */
10123function Pointer ($ref, path, friendlyPath) {
10124 /**
10125 * The {@link $Ref} object that contains this {@link Pointer} object.
10126 * @type {$Ref}
10127 */
10128 this.$ref = $ref;
10129
10130 /**
10131 * The file path or URL, containing the JSON pointer in the hash.
10132 * This path is relative to the path of the main JSON schema file.
10133 * @type {string}
10134 */
10135 this.path = path;
10136
10137 /**
10138 * The original path or URL, used for error messages.
10139 * @type {string}
10140 */
10141 this.originalPath = friendlyPath || path;
10142
10143 /**
10144 * The value of the JSON pointer.
10145 * Can be any JSON type, not just objects. Unknown file types are represented as Buffers (byte arrays).
10146 * @type {?*}
10147 */
10148 this.value = undefined;
10149
10150 /**
10151 * Indicates whether the pointer references itself.
10152 * @type {boolean}
10153 */
10154 this.circular = false;
10155
10156 /**
10157 * The number of indirect references that were traversed to resolve the value.
10158 * Resolving a single pointer may require resolving multiple $Refs.
10159 * @type {number}
10160 */
10161 this.indirections = 0;
10162}
10163
10164/**
10165 * Resolves the value of a nested property within the given object.
10166 *
10167 * @param {*} obj - The object that will be crawled
10168 * @param {$RefParserOptions} options
10169 *
10170 * @returns {Pointer}
10171 * Returns a JSON pointer whose {@link Pointer#value} is the resolved value.
10172 * If resolving this value required resolving other JSON references, then
10173 * the {@link Pointer#$ref} and {@link Pointer#path} will reflect the resolution path
10174 * of the resolved value.
10175 */
10176Pointer.prototype.resolve = function (obj, options) {
10177 var tokens = Pointer.parse(this.path);
10178
10179 // Crawl the object, one token at a time
10180 this.value = obj;
10181 for (var i = 0; i < tokens.length; i++) {
10182 if (resolveIf$Ref(this, options)) {
10183 // The $ref path has changed, so append the remaining tokens to the path
10184 this.path = Pointer.join(this.path, tokens.slice(i));
10185 }
10186
10187 var token = tokens[i];
10188 if (this.value[token] === undefined) {
10189 throw ono.syntax('Error resolving $ref pointer "%s". \nToken "%s" does not exist.', this.originalPath, token);
10190 }
10191 else {
10192 this.value = this.value[token];
10193 }
10194 }
10195
10196 // Resolve the final value
10197 resolveIf$Ref(this, options);
10198 return this;
10199};
10200
10201/**
10202 * Sets the value of a nested property within the given object.
10203 *
10204 * @param {*} obj - The object that will be crawled
10205 * @param {*} value - the value to assign
10206 * @param {$RefParserOptions} options
10207 *
10208 * @returns {*}
10209 * Returns the modified object, or an entirely new object if the entire object is overwritten.
10210 */
10211Pointer.prototype.set = function (obj, value, options) {
10212 var tokens = Pointer.parse(this.path);
10213 var token;
10214
10215 if (tokens.length === 0) {
10216 // There are no tokens, replace the entire object with the new value
10217 this.value = value;
10218 return value;
10219 }
10220
10221 // Crawl the object, one token at a time
10222 this.value = obj;
10223 for (var i = 0; i < tokens.length - 1; i++) {
10224 resolveIf$Ref(this, options);
10225
10226 token = tokens[i];
10227 if (this.value && this.value[token] !== undefined) {
10228 // The token exists
10229 this.value = this.value[token];
10230 }
10231 else {
10232 // The token doesn't exist, so create it
10233 this.value = setValue(this, token, {});
10234 }
10235 }
10236
10237 // Set the value of the final token
10238 resolveIf$Ref(this, options);
10239 token = tokens[tokens.length - 1];
10240 setValue(this, token, value);
10241
10242 // Return the updated object
10243 return obj;
10244};
10245
10246/**
10247 * Parses a JSON pointer (or a path containing a JSON pointer in the hash)
10248 * and returns an array of the pointer's tokens.
10249 * (e.g. "schema.json#/definitions/person/name" => ["definitions", "person", "name"])
10250 *
10251 * The pointer is parsed according to RFC 6901
10252 * {@link https://tools.ietf.org/html/rfc6901#section-3}
10253 *
10254 * @param {string} path
10255 * @returns {string[]}
10256 */
10257Pointer.parse = function (path) {
10258 // Get the JSON pointer from the path's hash
10259 var pointer = url.getHash(path).substr(1);
10260
10261 // If there's no pointer, then there are no tokens,
10262 // so return an empty array
10263 if (!pointer) {
10264 return [];
10265 }
10266
10267 // Split into an array
10268 pointer = pointer.split("/");
10269
10270 // Decode each part, according to RFC 6901
10271 for (var i = 0; i < pointer.length; i++) {
10272 pointer[i] = decodeURIComponent(pointer[i].replace(escapedSlash, "/").replace(escapedTilde, "~"));
10273 }
10274
10275 if (pointer[0] !== "") {
10276 throw ono.syntax('Invalid $ref pointer "%s". Pointers must begin with "#/"', pointer);
10277 }
10278
10279 return pointer.slice(1);
10280};
10281
10282/**
10283 * Creates a JSON pointer path, by joining one or more tokens to a base path.
10284 *
10285 * @param {string} base - The base path (e.g. "schema.json#/definitions/person")
10286 * @param {string|string[]} tokens - The token(s) to append (e.g. ["name", "first"])
10287 * @returns {string}
10288 */
10289Pointer.join = function (base, tokens) {
10290 // Ensure that the base path contains a hash
10291 if (base.indexOf("#") === -1) {
10292 base += "#";
10293 }
10294
10295 // Append each token to the base path
10296 tokens = Array.isArray(tokens) ? tokens : [tokens];
10297 for (var i = 0; i < tokens.length; i++) {
10298 var token = tokens[i];
10299 // Encode the token, according to RFC 6901
10300 base += "/" + encodeURIComponent(token.replace(tildes, "~0").replace(slashes, "~1"));
10301 }
10302
10303 return base;
10304};
10305
10306/**
10307 * If the given pointer's {@link Pointer#value} is a JSON reference,
10308 * then the reference is resolved and {@link Pointer#value} is replaced with the resolved value.
10309 * In addition, {@link Pointer#path} and {@link Pointer#$ref} are updated to reflect the
10310 * resolution path of the new value.
10311 *
10312 * @param {Pointer} pointer
10313 * @param {$RefParserOptions} options
10314 * @returns {boolean} - Returns `true` if the resolution path changed
10315 */
10316function resolveIf$Ref (pointer, options) {
10317 // Is the value a JSON reference? (and allowed?)
10318
10319 if ($Ref.isAllowed$Ref(pointer.value, options)) {
10320 var $refPath = url.resolve(pointer.path, pointer.value.$ref);
10321
10322 if ($refPath === pointer.path) {
10323 // The value is a reference to itself, so there's nothing to do.
10324 pointer.circular = true;
10325 }
10326 else {
10327 var resolved = pointer.$ref.$refs._resolve($refPath, options);
10328 pointer.indirections += resolved.indirections + 1;
10329
10330 if ($Ref.isExtended$Ref(pointer.value)) {
10331 // This JSON reference "extends" the resolved value, rather than simply pointing to it.
10332 // So the resolved path does NOT change. Just the value does.
10333 pointer.value = $Ref.dereference(pointer.value, resolved.value);
10334 return false;
10335 }
10336 else {
10337 // Resolve the reference
10338 pointer.$ref = resolved.$ref;
10339 pointer.path = resolved.path;
10340 pointer.value = resolved.value;
10341 }
10342
10343 return true;
10344 }
10345 }
10346}
10347
10348/**
10349 * Sets the specified token value of the {@link Pointer#value}.
10350 *
10351 * The token is evaluated according to RFC 6901.
10352 * {@link https://tools.ietf.org/html/rfc6901#section-4}
10353 *
10354 * @param {Pointer} pointer - The JSON Pointer whose value will be modified
10355 * @param {string} token - A JSON Pointer token that indicates how to modify `obj`
10356 * @param {*} value - The value to assign
10357 * @returns {*} - Returns the assigned value
10358 */
10359function setValue (pointer, token, value) {
10360 if (pointer.value && typeof pointer.value === "object") {
10361 if (token === "-" && Array.isArray(pointer.value)) {
10362 pointer.value.push(value);
10363 }
10364 else {
10365 pointer.value[token] = value;
10366 }
10367 }
10368 else {
10369 throw ono.syntax('Error assigning $ref pointer "%s". \nCannot set "%s" of a non-object.', pointer.path, token);
10370 }
10371 return value;
10372}
10373
10374},{"./ref":112,"./util/url":118,"ono":122}],112:[function(require,module,exports){
10375"use strict";
10376
10377module.exports = $Ref;
10378
10379var Pointer = require("./pointer");
10380
10381/**
10382 * This class represents a single JSON reference and its resolved value.
10383 *
10384 * @constructor
10385 */
10386function $Ref () {
10387 /**
10388 * The file path or URL of the referenced file.
10389 * This path is relative to the path of the main JSON schema file.
10390 *
10391 * This path does NOT contain document fragments (JSON pointers). It always references an ENTIRE file.
10392 * Use methods such as {@link $Ref#get}, {@link $Ref#resolve}, and {@link $Ref#exists} to get
10393 * specific JSON pointers within the file.
10394 *
10395 * @type {string}
10396 */
10397 this.path = undefined;
10398
10399 /**
10400 * The resolved value of the JSON reference.
10401 * Can be any JSON type, not just objects. Unknown file types are represented as Buffers (byte arrays).
10402 * @type {?*}
10403 */
10404 this.value = undefined;
10405
10406 /**
10407 * The {@link $Refs} object that contains this {@link $Ref} object.
10408 * @type {$Refs}
10409 */
10410 this.$refs = undefined;
10411
10412 /**
10413 * Indicates the type of {@link $Ref#path} (e.g. "file", "http", etc.)
10414 * @type {?string}
10415 */
10416 this.pathType = undefined;
10417}
10418
10419/**
10420 * Determines whether the given JSON reference exists within this {@link $Ref#value}.
10421 *
10422 * @param {string} path - The full path being resolved, optionally with a JSON pointer in the hash
10423 * @param {$RefParserOptions} options
10424 * @returns {boolean}
10425 */
10426$Ref.prototype.exists = function (path, options) {
10427 try {
10428 this.resolve(path, options);
10429 return true;
10430 }
10431 catch (e) {
10432 return false;
10433 }
10434};
10435
10436/**
10437 * Resolves the given JSON reference within this {@link $Ref#value} and returns the resolved value.
10438 *
10439 * @param {string} path - The full path being resolved, optionally with a JSON pointer in the hash
10440 * @param {$RefParserOptions} options
10441 * @returns {*} - Returns the resolved value
10442 */
10443$Ref.prototype.get = function (path, options) {
10444 return this.resolve(path, options).value;
10445};
10446
10447/**
10448 * Resolves the given JSON reference within this {@link $Ref#value}.
10449 *
10450 * @param {string} path - The full path being resolved, optionally with a JSON pointer in the hash
10451 * @param {$RefParserOptions} options
10452 * @param {string} [friendlyPath] - The original user-specified path (used for error messages)
10453 * @returns {Pointer}
10454 */
10455$Ref.prototype.resolve = function (path, options, friendlyPath) {
10456 var pointer = new Pointer(this, path, friendlyPath);
10457 return pointer.resolve(this.value, options);
10458};
10459
10460/**
10461 * Sets the value of a nested property within this {@link $Ref#value}.
10462 * If the property, or any of its parents don't exist, they will be created.
10463 *
10464 * @param {string} path - The full path of the property to set, optionally with a JSON pointer in the hash
10465 * @param {*} value - The value to assign
10466 */
10467$Ref.prototype.set = function (path, value) {
10468 var pointer = new Pointer(this, path);
10469 this.value = pointer.set(this.value, value);
10470};
10471
10472/**
10473 * Determines whether the given value is a JSON reference.
10474 *
10475 * @param {*} value - The value to inspect
10476 * @returns {boolean}
10477 */
10478$Ref.is$Ref = function (value) {
10479 return value && typeof value === "object" && typeof value.$ref === "string" && value.$ref.length > 0;
10480};
10481
10482/**
10483 * Determines whether the given value is an external JSON reference.
10484 *
10485 * @param {*} value - The value to inspect
10486 * @returns {boolean}
10487 */
10488$Ref.isExternal$Ref = function (value) {
10489 return $Ref.is$Ref(value) && value.$ref[0] !== "#";
10490};
10491
10492/**
10493 * Determines whether the given value is a JSON reference, and whether it is allowed by the options.
10494 * For example, if it references an external file, then options.resolve.external must be true.
10495 *
10496 * @param {*} value - The value to inspect
10497 * @param {$RefParserOptions} options
10498 * @returns {boolean}
10499 */
10500$Ref.isAllowed$Ref = function (value, options) {
10501 if ($Ref.is$Ref(value)) {
10502 if (value.$ref.substr(0, 2) === "#/" || value.$ref === "#") {
10503 // It's a JSON Pointer reference, which is always allowed
10504 return true;
10505 }
10506 else if (value.$ref[0] !== "#" && (!options || options.resolve.external)) {
10507 // It's an external reference, which is allowed by the options
10508 return true;
10509 }
10510 }
10511};
10512
10513/**
10514 * Determines whether the given value is a JSON reference that "extends" its resolved value.
10515 * That is, it has extra properties (in addition to "$ref"), so rather than simply pointing to
10516 * an existing value, this $ref actually creates a NEW value that is a shallow copy of the resolved
10517 * value, plus the extra properties.
10518 *
10519 * @example:
10520 * {
10521 * person: {
10522 * properties: {
10523 * firstName: { type: string }
10524 * lastName: { type: string }
10525 * }
10526 * }
10527 * employee: {
10528 * properties: {
10529 * $ref: #/person/properties
10530 * salary: { type: number }
10531 * }
10532 * }
10533 * }
10534 *
10535 * In this example, "employee" is an extended $ref, since it extends "person" with an additional
10536 * property (salary). The result is a NEW value that looks like this:
10537 *
10538 * {
10539 * properties: {
10540 * firstName: { type: string }
10541 * lastName: { type: string }
10542 * salary: { type: number }
10543 * }
10544 * }
10545 *
10546 * @param {*} value - The value to inspect
10547 * @returns {boolean}
10548 */
10549$Ref.isExtended$Ref = function (value) {
10550 return $Ref.is$Ref(value) && Object.keys(value).length > 1;
10551};
10552
10553/**
10554 * Returns the resolved value of a JSON Reference.
10555 * If necessary, the resolved value is merged with the JSON Reference to create a new object
10556 *
10557 * @example:
10558 * {
10559 * person: {
10560 * properties: {
10561 * firstName: { type: string }
10562 * lastName: { type: string }
10563 * }
10564 * }
10565 * employee: {
10566 * properties: {
10567 * $ref: #/person/properties
10568 * salary: { type: number }
10569 * }
10570 * }
10571 * }
10572 *
10573 * When "person" and "employee" are merged, you end up with the following object:
10574 *
10575 * {
10576 * properties: {
10577 * firstName: { type: string }
10578 * lastName: { type: string }
10579 * salary: { type: number }
10580 * }
10581 * }
10582 *
10583 * @param {object} $ref - The JSON reference object (the one with the "$ref" property)
10584 * @param {*} resolvedValue - The resolved value, which can be any type
10585 * @returns {*} - Returns the dereferenced value
10586 */
10587$Ref.dereference = function ($ref, resolvedValue) {
10588 if (resolvedValue && typeof resolvedValue === "object" && $Ref.isExtended$Ref($ref)) {
10589 var merged = {};
10590 Object.keys($ref).forEach(function (key) {
10591 if (key !== "$ref") {
10592 merged[key] = $ref[key];
10593 }
10594 });
10595 Object.keys(resolvedValue).forEach(function (key) {
10596 if (!(key in merged)) {
10597 merged[key] = resolvedValue[key];
10598 }
10599 });
10600 return merged;
10601 }
10602 else {
10603 // Completely replace the original reference with the resolved value
10604 return resolvedValue;
10605 }
10606};
10607
10608},{"./pointer":111}],113:[function(require,module,exports){
10609"use strict";
10610
10611var ono = require("ono"),
10612 $Ref = require("./ref"),
10613 url = require("./util/url");
10614
10615module.exports = $Refs;
10616
10617/**
10618 * This class is a map of JSON references and their resolved values.
10619 */
10620function $Refs () {
10621 /**
10622 * Indicates whether the schema contains any circular references.
10623 *
10624 * @type {boolean}
10625 */
10626 this.circular = false;
10627
10628 /**
10629 * A map of paths/urls to {@link $Ref} objects
10630 *
10631 * @type {object}
10632 * @protected
10633 */
10634 this._$refs = {};
10635
10636 /**
10637 * The {@link $Ref} object that is the root of the JSON schema.
10638 *
10639 * @type {$Ref}
10640 * @protected
10641 */
10642 this._root$Ref = null;
10643}
10644
10645/**
10646 * Returns the paths of all the files/URLs that are referenced by the JSON schema,
10647 * including the schema itself.
10648 *
10649 * @param {...string|string[]} [types] - Only return paths of the given types ("file", "http", etc.)
10650 * @returns {string[]}
10651 */
10652$Refs.prototype.paths = function (types) {
10653 var paths = getPaths(this._$refs, arguments);
10654 return paths.map(function (path) {
10655 return path.decoded;
10656 });
10657};
10658
10659/**
10660 * Returns the map of JSON references and their resolved values.
10661 *
10662 * @param {...string|string[]} [types] - Only return references of the given types ("file", "http", etc.)
10663 * @returns {object}
10664 */
10665$Refs.prototype.values = function (types) {
10666 var $refs = this._$refs;
10667 var paths = getPaths($refs, arguments);
10668 return paths.reduce(function (obj, path) {
10669 obj[path.decoded] = $refs[path.encoded].value;
10670 return obj;
10671 }, {});
10672};
10673
10674/**
10675 * Returns a POJO (plain old JavaScript object) for serialization as JSON.
10676 *
10677 * @returns {object}
10678 */
10679$Refs.prototype.toJSON = $Refs.prototype.values;
10680
10681/**
10682 * Determines whether the given JSON reference exists.
10683 *
10684 * @param {string} path - The path being resolved, optionally with a JSON pointer in the hash
10685 * @param {$RefParserOptions} [options]
10686 * @returns {boolean}
10687 */
10688$Refs.prototype.exists = function (path, options) {
10689 try {
10690 this._resolve(path, options);
10691 return true;
10692 }
10693 catch (e) {
10694 return false;
10695 }
10696};
10697
10698/**
10699 * Resolves the given JSON reference and returns the resolved value.
10700 *
10701 * @param {string} path - The path being resolved, with a JSON pointer in the hash
10702 * @param {$RefParserOptions} [options]
10703 * @returns {*} - Returns the resolved value
10704 */
10705$Refs.prototype.get = function (path, options) {
10706 return this._resolve(path, options).value;
10707};
10708
10709/**
10710 * Sets the value of a nested property within this {@link $Ref#value}.
10711 * If the property, or any of its parents don't exist, they will be created.
10712 *
10713 * @param {string} path - The path of the property to set, optionally with a JSON pointer in the hash
10714 * @param {*} value - The value to assign
10715 */
10716$Refs.prototype.set = function (path, value) {
10717 var absPath = url.resolve(this._root$Ref.path, path);
10718 var withoutHash = url.stripHash(absPath);
10719 var $ref = this._$refs[withoutHash];
10720
10721 if (!$ref) {
10722 throw ono('Error resolving $ref pointer "%s". \n"%s" not found.', path, withoutHash);
10723 }
10724
10725 $ref.set(absPath, value);
10726};
10727
10728/**
10729 * Creates a new {@link $Ref} object and adds it to this {@link $Refs} object.
10730 *
10731 * @param {string} path - The file path or URL of the referenced file
10732 */
10733$Refs.prototype._add = function (path) {
10734 var withoutHash = url.stripHash(path);
10735
10736 var $ref = new $Ref();
10737 $ref.path = withoutHash;
10738 $ref.$refs = this;
10739
10740 this._$refs[withoutHash] = $ref;
10741 this._root$Ref = this._root$Ref || $ref;
10742
10743 return $ref;
10744};
10745
10746/**
10747 * Resolves the given JSON reference.
10748 *
10749 * @param {string} path - The path being resolved, optionally with a JSON pointer in the hash
10750 * @param {$RefParserOptions} [options]
10751 * @returns {Pointer}
10752 * @protected
10753 */
10754$Refs.prototype._resolve = function (path, options) {
10755 var absPath = url.resolve(this._root$Ref.path, path);
10756 var withoutHash = url.stripHash(absPath);
10757 var $ref = this._$refs[withoutHash];
10758
10759 if (!$ref) {
10760 throw ono('Error resolving $ref pointer "%s". \n"%s" not found.', path, withoutHash);
10761 }
10762
10763 return $ref.resolve(absPath, options, path);
10764};
10765
10766/**
10767 * Returns the specified {@link $Ref} object, or undefined.
10768 *
10769 * @param {string} path - The path being resolved, optionally with a JSON pointer in the hash
10770 * @returns {$Ref|undefined}
10771 * @protected
10772 */
10773$Refs.prototype._get$Ref = function (path) {
10774 path = url.resolve(this._root$Ref.path, path);
10775 var withoutHash = url.stripHash(path);
10776 return this._$refs[withoutHash];
10777};
10778
10779/**
10780 * Returns the encoded and decoded paths keys of the given object.
10781 *
10782 * @param {object} $refs - The object whose keys are URL-encoded paths
10783 * @param {...string|string[]} [types] - Only return paths of the given types ("file", "http", etc.)
10784 * @returns {object[]}
10785 */
10786function getPaths ($refs, types) {
10787 var paths = Object.keys($refs);
10788
10789 // Filter the paths by type
10790 types = Array.isArray(types[0]) ? types[0] : Array.prototype.slice.call(types);
10791 if (types.length > 0 && types[0]) {
10792 paths = paths.filter(function (key) {
10793 return types.indexOf($refs[key].pathType) !== -1;
10794 });
10795 }
10796
10797 // Decode local filesystem paths
10798 return paths.map(function (path) {
10799 return {
10800 encoded: path,
10801 decoded: $refs[path].pathType === "file" ? url.toFileSystemPath(path, true) : path
10802 };
10803 });
10804}
10805
10806},{"./ref":112,"./util/url":118,"ono":122}],114:[function(require,module,exports){
10807"use strict";
10808
10809var $Ref = require("./ref"),
10810 Pointer = require("./pointer"),
10811 parse = require("./parse"),
10812 url = require("./util/url");
10813
10814module.exports = resolveExternal;
10815
10816/**
10817 * Crawls the JSON schema, finds all external JSON references, and resolves their values.
10818 * This method does not mutate the JSON schema. The resolved values are added to {@link $RefParser#$refs}.
10819 *
10820 * NOTE: We only care about EXTERNAL references here. INTERNAL references are only relevant when dereferencing.
10821 *
10822 * @param {$RefParser} parser
10823 * @param {$RefParserOptions} options
10824 *
10825 * @returns {Promise}
10826 * The promise resolves once all JSON references in the schema have been resolved,
10827 * including nested references that are contained in externally-referenced files.
10828 */
10829function resolveExternal (parser, options) {
10830 if (!options.resolve.external) {
10831 // Nothing to resolve, so exit early
10832 return Promise.resolve();
10833 }
10834
10835 try {
10836 // console.log('Resolving $ref pointers in %s', parser.$refs._root$Ref.path);
10837 var promises = crawl(parser.schema, parser.$refs._root$Ref.path + "#", parser.$refs, options);
10838 return Promise.all(promises);
10839 }
10840 catch (e) {
10841 return Promise.reject(e);
10842 }
10843}
10844
10845/**
10846 * Recursively crawls the given value, and resolves any external JSON references.
10847 *
10848 * @param {*} obj - The value to crawl. If it's not an object or array, it will be ignored.
10849 * @param {string} path - The full path of `obj`, possibly with a JSON Pointer in the hash
10850 * @param {$Refs} $refs
10851 * @param {$RefParserOptions} options
10852 *
10853 * @returns {Promise[]}
10854 * Returns an array of promises. There will be one promise for each JSON reference in `obj`.
10855 * If `obj` does not contain any JSON references, then the array will be empty.
10856 * If any of the JSON references point to files that contain additional JSON references,
10857 * then the corresponding promise will internally reference an array of promises.
10858 */
10859function crawl (obj, path, $refs, options) {
10860 var promises = [];
10861
10862 if (obj && typeof obj === "object") {
10863 if ($Ref.isExternal$Ref(obj)) {
10864 promises.push(resolve$Ref(obj, path, $refs, options));
10865 }
10866 else {
10867 Object.keys(obj).forEach(function (key) {
10868 var keyPath = Pointer.join(path, key);
10869 var value = obj[key];
10870
10871 if ($Ref.isExternal$Ref(value)) {
10872 promises.push(resolve$Ref(value, keyPath, $refs, options));
10873 }
10874 else {
10875 promises = promises.concat(crawl(value, keyPath, $refs, options));
10876 }
10877 });
10878 }
10879 }
10880
10881 return promises;
10882}
10883
10884/**
10885 * Resolves the given JSON Reference, and then crawls the resulting value.
10886 *
10887 * @param {{$ref: string}} $ref - The JSON Reference to resolve
10888 * @param {string} path - The full path of `$ref`, possibly with a JSON Pointer in the hash
10889 * @param {$Refs} $refs
10890 * @param {$RefParserOptions} options
10891 *
10892 * @returns {Promise}
10893 * The promise resolves once all JSON references in the object have been resolved,
10894 * including nested references that are contained in externally-referenced files.
10895 */
10896function resolve$Ref ($ref, path, $refs, options) {
10897 // console.log('Resolving $ref pointer "%s" at %s', $ref.$ref, path);
10898
10899 var resolvedPath = url.resolve(path, $ref.$ref);
10900 var withoutHash = url.stripHash(resolvedPath);
10901
10902 // Do we already have this $ref?
10903 $ref = $refs._$refs[withoutHash];
10904 if ($ref) {
10905 // We've already parsed this $ref, so use the existing value
10906 return Promise.resolve($ref.value);
10907 }
10908
10909 // Parse the $referenced file/url
10910 return parse(resolvedPath, $refs, options)
10911 .then(function (result) {
10912 // Crawl the parsed value
10913 // console.log('Resolving $ref pointers in %s', withoutHash);
10914 var promises = crawl(result, withoutHash + "#", $refs, options);
10915 return Promise.all(promises);
10916 });
10917}
10918
10919},{"./parse":106,"./pointer":111,"./ref":112,"./util/url":118}],115:[function(require,module,exports){
10920"use strict";
10921var fs = require("fs"),
10922 ono = require("ono"),
10923 url = require("../util/url");
10924
10925module.exports = {
10926 /**
10927 * The order that this resolver will run, in relation to other resolvers.
10928 *
10929 * @type {number}
10930 */
10931 order: 100,
10932
10933 /**
10934 * Determines whether this resolver can read a given file reference.
10935 * Resolvers that return true will be tried, in order, until one successfully resolves the file.
10936 * Resolvers that return false will not be given a chance to resolve the file.
10937 *
10938 * @param {object} file - An object containing information about the referenced file
10939 * @param {string} file.url - The full URL of the referenced file
10940 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
10941 * @returns {boolean}
10942 */
10943 canRead: function isFile (file) {
10944 return url.isFileSystemPath(file.url);
10945 },
10946
10947 /**
10948 * Reads the given file and returns its raw contents as a Buffer.
10949 *
10950 * @param {object} file - An object containing information about the referenced file
10951 * @param {string} file.url - The full URL of the referenced file
10952 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
10953 * @returns {Promise<Buffer>}
10954 */
10955 read: function readFile (file) {
10956 return new Promise(function (resolve, reject) {
10957 var path;
10958 try {
10959 path = url.toFileSystemPath(file.url);
10960 }
10961 catch (err) {
10962 reject(ono.uri(err, "Malformed URI: %s", file.url));
10963 }
10964
10965 // console.log('Opening file: %s', path);
10966
10967 try {
10968 fs.readFile(path, function (err, data) {
10969 if (err) {
10970 reject(ono(err, 'Error opening file "%s"', path));
10971 }
10972 else {
10973 resolve(data);
10974 }
10975 });
10976 }
10977 catch (err) {
10978 reject(ono(err, 'Error opening file "%s"', path));
10979 }
10980 });
10981 }
10982};
10983
10984},{"../util/url":118,"fs":7,"ono":122}],116:[function(require,module,exports){
10985(function (process,Buffer){
10986"use strict";
10987
10988var http = require("http"),
10989 https = require("https"),
10990 ono = require("ono"),
10991 url = require("../util/url");
10992
10993module.exports = {
10994 /**
10995 * The order that this resolver will run, in relation to other resolvers.
10996 *
10997 * @type {number}
10998 */
10999 order: 200,
11000
11001 /**
11002 * HTTP headers to send when downloading files.
11003 *
11004 * @example:
11005 * {
11006 * "User-Agent": "JSON Schema $Ref Parser",
11007 * Accept: "application/json"
11008 * }
11009 *
11010 * @type {object}
11011 */
11012 headers: null,
11013
11014 /**
11015 * HTTP request timeout (in milliseconds).
11016 *
11017 * @type {number}
11018 */
11019 timeout: 5000, // 5 seconds
11020
11021 /**
11022 * The maximum number of HTTP redirects to follow.
11023 * To disable automatic following of redirects, set this to zero.
11024 *
11025 * @type {number}
11026 */
11027 redirects: 5,
11028
11029 /**
11030 * The `withCredentials` option of XMLHttpRequest.
11031 * Set this to `true` if you're downloading files from a CORS-enabled server that requires authentication
11032 *
11033 * @type {boolean}
11034 */
11035 withCredentials: false,
11036
11037 /**
11038 * Determines whether this resolver can read a given file reference.
11039 * Resolvers that return true will be tried in order, until one successfully resolves the file.
11040 * Resolvers that return false will not be given a chance to resolve the file.
11041 *
11042 * @param {object} file - An object containing information about the referenced file
11043 * @param {string} file.url - The full URL of the referenced file
11044 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
11045 * @returns {boolean}
11046 */
11047 canRead: function isHttp (file) {
11048 return url.isHttp(file.url);
11049 },
11050
11051 /**
11052 * Reads the given URL and returns its raw contents as a Buffer.
11053 *
11054 * @param {object} file - An object containing information about the referenced file
11055 * @param {string} file.url - The full URL of the referenced file
11056 * @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
11057 * @returns {Promise<Buffer>}
11058 */
11059 read: function readHttp (file) {
11060 var u = url.parse(file.url);
11061
11062 if (process.browser && !u.protocol) {
11063 // Use the protocol of the current page
11064 u.protocol = url.parse(location.href).protocol;
11065 }
11066
11067 return download(u, this);
11068 }
11069};
11070
11071/**
11072 * Downloads the given file.
11073 *
11074 * @param {Url|string} u - The url to download (can be a parsed {@link Url} object)
11075 * @param {object} httpOptions - The `options.resolve.http` object
11076 * @param {number} [redirects] - The redirect URLs that have already been followed
11077 *
11078 * @returns {Promise<Buffer>}
11079 * The promise resolves with the raw downloaded data, or rejects if there is an HTTP error.
11080 */
11081function download (u, httpOptions, redirects) {
11082 return new Promise(function (resolve, reject) {
11083 u = url.parse(u);
11084 redirects = redirects || [];
11085 redirects.push(u.href);
11086
11087 get(u, httpOptions)
11088 .then(function (res) {
11089 if (res.statusCode >= 400) {
11090 throw ono({ status: res.statusCode }, "HTTP ERROR %d", res.statusCode);
11091 }
11092 else if (res.statusCode >= 300) {
11093 if (redirects.length > httpOptions.redirects) {
11094 reject(ono({ status: res.statusCode }, "Error downloading %s. \nToo many redirects: \n %s",
11095 redirects[0], redirects.join(" \n ")));
11096 }
11097 else if (!res.headers.location) {
11098 throw ono({ status: res.statusCode }, "HTTP %d redirect with no location header", res.statusCode);
11099 }
11100 else {
11101 // console.log('HTTP %d redirect %s -> %s', res.statusCode, u.href, res.headers.location);
11102 var redirectTo = url.resolve(u, res.headers.location);
11103 download(redirectTo, httpOptions, redirects).then(resolve, reject);
11104 }
11105 }
11106 else {
11107 resolve(res.body || new Buffer(0));
11108 }
11109 })
11110 .catch(function (err) {
11111 reject(ono(err, "Error downloading", u.href));
11112 });
11113 });
11114}
11115
11116/**
11117 * Sends an HTTP GET request.
11118 *
11119 * @param {Url} u - A parsed {@link Url} object
11120 * @param {object} httpOptions - The `options.resolve.http` object
11121 *
11122 * @returns {Promise<Response>}
11123 * The promise resolves with the HTTP Response object.
11124 */
11125function get (u, httpOptions) {
11126 return new Promise(function (resolve, reject) {
11127 // console.log('GET', u.href);
11128
11129 var protocol = u.protocol === "https:" ? https : http;
11130 var req = protocol.get({
11131 hostname: u.hostname,
11132 port: u.port,
11133 path: u.path,
11134 auth: u.auth,
11135 protocol: u.protocol,
11136 headers: httpOptions.headers || {},
11137 withCredentials: httpOptions.withCredentials
11138 });
11139
11140 if (typeof req.setTimeout === "function") {
11141 req.setTimeout(httpOptions.timeout);
11142 }
11143
11144 req.on("timeout", function () {
11145 req.abort();
11146 });
11147
11148 req.on("error", reject);
11149
11150 req.once("response", function (res) {
11151 res.body = new Buffer(0);
11152
11153 res.on("data", function (data) {
11154 res.body = Buffer.concat([res.body, new Buffer(data)]);
11155 });
11156
11157 res.on("error", reject);
11158
11159 res.on("end", function () {
11160 resolve(res);
11161 });
11162 });
11163 });
11164}
11165
11166}).call(this,require('_process'),require("buffer").Buffer)
11167
11168},{"../util/url":118,"_process":125,"buffer":9,"http":139,"https":66,"ono":122}],117:[function(require,module,exports){
11169"use strict";
11170
11171/**
11172 * Returns the given plugins as an array, rather than an object map.
11173 * All other methods in this module expect an array of plugins rather than an object map.
11174 *
11175 * @param {object} plugins - A map of plugin objects
11176 * @return {object[]}
11177 */
11178exports.all = function (plugins) {
11179 return Object.keys(plugins)
11180 .filter(function (key) {
11181 return typeof plugins[key] === "object";
11182 })
11183 .map(function (key) {
11184 plugins[key].name = key;
11185 return plugins[key];
11186 });
11187};
11188
11189/**
11190 * Filters the given plugins, returning only the ones return `true` for the given method.
11191 *
11192 * @param {object[]} plugins - An array of plugin objects
11193 * @param {string} method - The name of the filter method to invoke for each plugin
11194 * @param {object} file - A file info object, which will be passed to each method
11195 * @return {object[]}
11196 */
11197exports.filter = function (plugins, method, file) {
11198 return plugins
11199 .filter(function (plugin) {
11200 return !!getResult(plugin, method, file);
11201 });
11202};
11203
11204/**
11205 * Sorts the given plugins, in place, by their `order` property.
11206 *
11207 * @param {object[]} plugins - An array of plugin objects
11208 * @returns {object[]}
11209 */
11210exports.sort = function (plugins) {
11211 plugins.forEach(function (plugin) {
11212 plugin.order = plugin.order || Number.MAX_SAFE_INTEGER;
11213 });
11214
11215 return plugins.sort(function (a, b) { return a.order - b.order; });
11216};
11217
11218/**
11219 * Runs the specified method of the given plugins, in order, until one of them returns a successful result.
11220 * Each method can return a synchronous value, a Promise, or call an error-first callback.
11221 * If the promise resolves successfully, or the callback is called without an error, then the result
11222 * is immediately returned and no further plugins are called.
11223 * If the promise rejects, or the callback is called with an error, then the next plugin is called.
11224 * If ALL plugins fail, then the last error is thrown.
11225 *
11226 * @param {object[]} plugins - An array of plugin objects
11227 * @param {string} method - The name of the method to invoke for each plugin
11228 * @param {object} file - A file info object, which will be passed to each method
11229 * @returns {Promise}
11230 */
11231exports.run = function (plugins, method, file) {
11232 var plugin, lastError, index = 0;
11233
11234 return new Promise(function (resolve, reject) {
11235 runNextPlugin();
11236
11237 function runNextPlugin () {
11238 plugin = plugins[index++];
11239 if (!plugin) {
11240 // There are no more functions, so re-throw the last error
11241 return reject(lastError);
11242 }
11243
11244 try {
11245 // console.log(' %s', plugin.name);
11246 var result = getResult(plugin, method, file, callback);
11247 if (result && typeof result.then === "function") {
11248 // A promise was returned
11249 result.then(onSuccess, onError);
11250 }
11251 else if (result !== undefined) {
11252 // A synchronous result was returned
11253 onSuccess(result);
11254 }
11255 // else { the callback will be called }
11256 }
11257 catch (e) {
11258 onError(e);
11259 }
11260 }
11261
11262 function callback (err, result) {
11263 if (err) {
11264 onError(err);
11265 }
11266 else {
11267 onSuccess(result);
11268 }
11269 }
11270
11271 function onSuccess (result) {
11272 // console.log(' success');
11273 resolve({
11274 plugin: plugin,
11275 result: result
11276 });
11277 }
11278
11279 function onError (err) {
11280 // console.log(' %s', err.message || err);
11281 lastError = err;
11282 runNextPlugin();
11283 }
11284 });
11285};
11286
11287/**
11288 * Returns the value of the given property.
11289 * If the property is a function, then the result of the function is returned.
11290 * If the value is a RegExp, then it will be tested against the file URL.
11291 * If the value is an aray, then it will be compared against the file extension.
11292 *
11293 * @param {object} obj - The object whose property/method is called
11294 * @param {string} prop - The name of the property/method to invoke
11295 * @param {object} file - A file info object, which will be passed to the method
11296 * @param {function} [callback] - A callback function, which will be passed to the method
11297 * @returns {*}
11298 */
11299function getResult (obj, prop, file, callback) {
11300 var value = obj[prop];
11301
11302 if (typeof value === "function") {
11303 return value.apply(obj, [file, callback]);
11304 }
11305
11306 if (!callback) {
11307 // The synchronous plugin functions (canParse and canRead)
11308 // allow a "shorthand" syntax, where the user can match
11309 // files by RegExp or by file extension.
11310 if (value instanceof RegExp) {
11311 return value.test(file.url);
11312 }
11313 else if (typeof value === "string") {
11314 return value === file.extension;
11315 }
11316 else if (Array.isArray(value)) {
11317 return value.indexOf(file.extension) !== -1;
11318 }
11319 }
11320
11321 return value;
11322}
11323
11324},{}],118:[function(require,module,exports){
11325(function (process){
11326"use strict";
11327
11328var isWindows = /^win/.test(process.platform),
11329 forwardSlashPattern = /\//g,
11330 protocolPattern = /^(\w{2,}):\/\//i,
11331 url = module.exports;
11332
11333// RegExp patterns to URL-encode special characters in local filesystem paths
11334var urlEncodePatterns = [
11335 /\?/g, "%3F",
11336 /\#/g, "%23",
11337];
11338
11339// RegExp patterns to URL-decode special characters for local filesystem paths
11340var urlDecodePatterns = [
11341 /\%23/g, "#",
11342 /\%24/g, "$",
11343 /\%26/g, "&",
11344 /\%2C/g, ",",
11345 /\%40/g, "@"
11346];
11347
11348exports.parse = require("url").parse;
11349exports.resolve = require("url").resolve;
11350
11351/**
11352 * Returns the current working directory (in Node) or the current page URL (in browsers).
11353 *
11354 * @returns {string}
11355 */
11356exports.cwd = function cwd () {
11357 return process.browser ? location.href : process.cwd() + "/";
11358};
11359
11360/**
11361 * Returns the protocol of the given URL, or `undefined` if it has no protocol.
11362 *
11363 * @param {string} path
11364 * @returns {?string}
11365 */
11366exports.getProtocol = function getProtocol (path) {
11367 var match = protocolPattern.exec(path);
11368 if (match) {
11369 return match[1].toLowerCase();
11370 }
11371};
11372
11373/**
11374 * Returns the lowercased file extension of the given URL,
11375 * or an empty string if it has no extension.
11376 *
11377 * @param {string} path
11378 * @returns {string}
11379 */
11380exports.getExtension = function getExtension (path) {
11381 var lastDot = path.lastIndexOf(".");
11382 if (lastDot >= 0) {
11383 return path.substr(lastDot).toLowerCase();
11384 }
11385 return "";
11386};
11387
11388/**
11389 * Returns the hash (URL fragment), of the given path.
11390 * If there is no hash, then the root hash ("#") is returned.
11391 *
11392 * @param {string} path
11393 * @returns {string}
11394 */
11395exports.getHash = function getHash (path) {
11396 var hashIndex = path.indexOf("#");
11397 if (hashIndex >= 0) {
11398 return path.substr(hashIndex);
11399 }
11400 return "#";
11401};
11402
11403/**
11404 * Removes the hash (URL fragment), if any, from the given path.
11405 *
11406 * @param {string} path
11407 * @returns {string}
11408 */
11409exports.stripHash = function stripHash (path) {
11410 var hashIndex = path.indexOf("#");
11411 if (hashIndex >= 0) {
11412 path = path.substr(0, hashIndex);
11413 }
11414 return path;
11415};
11416
11417/**
11418 * Determines whether the given path is an HTTP(S) URL.
11419 *
11420 * @param {string} path
11421 * @returns {boolean}
11422 */
11423exports.isHttp = function isHttp (path) {
11424 var protocol = url.getProtocol(path);
11425 if (protocol === "http" || protocol === "https") {
11426 return true;
11427 }
11428 else if (protocol === undefined) {
11429 // There is no protocol. If we're running in a browser, then assume it's HTTP.
11430 return process.browser;
11431 }
11432 else {
11433 // It's some other protocol, such as "ftp://", "mongodb://", etc.
11434 return false;
11435 }
11436};
11437
11438/**
11439 * Determines whether the given path is a filesystem path.
11440 * This includes "file://" URLs.
11441 *
11442 * @param {string} path
11443 * @returns {boolean}
11444 */
11445exports.isFileSystemPath = function isFileSystemPath (path) {
11446 if (process.browser) {
11447 // We're running in a browser, so assume that all paths are URLs.
11448 // This way, even relative paths will be treated as URLs rather than as filesystem paths
11449 return false;
11450 }
11451
11452 var protocol = url.getProtocol(path);
11453 return protocol === undefined || protocol === "file";
11454};
11455
11456/**
11457 * Converts a filesystem path to a properly-encoded URL.
11458 *
11459 * This is intended to handle situations where JSON Schema $Ref Parser is called
11460 * with a filesystem path that contains characters which are not allowed in URLs.
11461 *
11462 * @example
11463 * The following filesystem paths would be converted to the following URLs:
11464 *
11465 * <"!@#$%^&*+=?'>.json ==> %3C%22!@%23$%25%5E&*+=%3F\'%3E.json
11466 * C:\\My Documents\\File (1).json ==> C:/My%20Documents/File%20(1).json
11467 * file://Project #42/file.json ==> file://Project%20%2342/file.json
11468 *
11469 * @param {string} path
11470 * @returns {string}
11471 */
11472exports.fromFileSystemPath = function fromFileSystemPath (path) {
11473 // Step 1: On Windows, replace backslashes with forward slashes,
11474 // rather than encoding them as "%5C"
11475 if (isWindows) {
11476 path = path.replace(/\\/g, "/");
11477 }
11478
11479 // Step 2: `encodeURI` will take care of MOST characters
11480 path = encodeURI(path);
11481
11482 // Step 3: Manually encode characters that are not encoded by `encodeURI`.
11483 // This includes characters such as "#" and "?", which have special meaning in URLs,
11484 // but are just normal characters in a filesystem path.
11485 for (var i = 0; i < urlEncodePatterns.length; i += 2) {
11486 path = path.replace(urlEncodePatterns[i], urlEncodePatterns[i + 1]);
11487 }
11488
11489 return path;
11490};
11491
11492/**
11493 * Converts a URL to a local filesystem path.
11494 *
11495 * @param {string} path
11496 * @param {boolean} [keepFileProtocol] - If true, then "file://" will NOT be stripped
11497 * @returns {string}
11498 */
11499exports.toFileSystemPath = function toFileSystemPath (path, keepFileProtocol) {
11500 // Step 1: `decodeURI` will decode characters such as Cyrillic characters, spaces, etc.
11501 path = decodeURI(path);
11502
11503 // Step 2: Manually decode characters that are not decoded by `decodeURI`.
11504 // This includes characters such as "#" and "?", which have special meaning in URLs,
11505 // but are just normal characters in a filesystem path.
11506 for (var i = 0; i < urlDecodePatterns.length; i += 2) {
11507 path = path.replace(urlDecodePatterns[i], urlDecodePatterns[i + 1]);
11508 }
11509
11510 // Step 3: If it's a "file://" URL, then format it consistently
11511 // or convert it to a local filesystem path
11512 var isFileUrl = path.substr(0, 7).toLowerCase() === "file://";
11513 if (isFileUrl) {
11514 // Strip-off the protocol, and the initial "/", if there is one
11515 path = path[7] === "/" ? path.substr(8) : path.substr(7);
11516
11517 // insert a colon (":") after the drive letter on Windows
11518 if (isWindows && path[1] === "/") {
11519 path = path[0] + ":" + path.substr(1);
11520 }
11521
11522 if (keepFileProtocol) {
11523 // Return the consistently-formatted "file://" URL
11524 path = "file:///" + path;
11525 }
11526 else {
11527 // Convert the "file://" URL to a local filesystem path.
11528 // On Windows, it will start with something like "C:/".
11529 // On Posix, it will start with "/"
11530 isFileUrl = false;
11531 path = isWindows ? path : "/" + path;
11532 }
11533 }
11534
11535 // Step 4: Normalize Windows paths (unless it's a "file://" URL)
11536 if (isWindows && !isFileUrl) {
11537 // Replace forward slashes with backslashes
11538 path = path.replace(forwardSlashPattern, "\\");
11539
11540 // Capitalize the drive letter
11541 if (path.substr(1, 2) === ":\\") {
11542 path = path[0].toUpperCase() + path.substr(1);
11543 }
11544 }
11545
11546 return path;
11547};
11548
11549}).call(this,require('_process'))
11550
11551},{"_process":125,"url":148}],119:[function(require,module,exports){
11552/* eslint lines-around-comment: [2, {beforeBlockComment: false}] */
11553"use strict";
11554
11555var yaml = require("js-yaml"),
11556 ono = require("ono");
11557
11558/**
11559 * Simple YAML parsing functions, similar to {@link JSON.parse} and {@link JSON.stringify}
11560 */
11561module.exports = {
11562 /**
11563 * Parses a YAML string and returns the value.
11564 *
11565 * @param {string} text - The YAML string to be parsed
11566 * @param {function} [reviver] - Not currently supported. Provided for consistency with {@link JSON.parse}
11567 * @returns {*}
11568 */
11569 parse: function yamlParse (text, reviver) {
11570 try {
11571 return yaml.safeLoad(text);
11572 }
11573 catch (e) {
11574 if (e instanceof Error) {
11575 throw e;
11576 }
11577 else {
11578 // https://github.com/nodeca/js-yaml/issues/153
11579 throw ono(e, e.message);
11580 }
11581 }
11582 },
11583
11584 /**
11585 * Converts a JavaScript value to a YAML string.
11586 *
11587 * @param {*} value - The value to convert to YAML
11588 * @param {function|array} replacer - Not currently supported. Provided for consistency with {@link JSON.stringify}
11589 * @param {string|number} space - The number of spaces to use for indentation, or a string containing the number of spaces.
11590 * @returns {string}
11591 */
11592 stringify: function yamlStringify (value, replacer, space) {
11593 try {
11594 var indent = (typeof space === "string" ? space.length : space) || 2;
11595 return yaml.safeDump(value, { indent: indent });
11596 }
11597 catch (e) {
11598 if (e instanceof Error) {
11599 throw e;
11600 }
11601 else {
11602 // https://github.com/nodeca/js-yaml/issues/153
11603 throw ono(e, e.message);
11604 }
11605 }
11606 }
11607};
11608
11609},{"js-yaml":71,"ono":122}],120:[function(require,module,exports){
11610(function (global){
11611/**
11612 * lodash (Custom Build) <https://lodash.com/>
11613 * Build: `lodash modularize exports="npm" -o ./`
11614 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
11615 * Released under MIT license <https://lodash.com/license>
11616 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
11617 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11618 */
11619
11620/** Used as the `TypeError` message for "Functions" methods. */
11621var FUNC_ERROR_TEXT = 'Expected a function';
11622
11623/** Used to stand-in for `undefined` hash values. */
11624var HASH_UNDEFINED = '__lodash_hash_undefined__';
11625
11626/** Used as references for various `Number` constants. */
11627var INFINITY = 1 / 0;
11628
11629/** `Object#toString` result references. */
11630var funcTag = '[object Function]',
11631 genTag = '[object GeneratorFunction]',
11632 symbolTag = '[object Symbol]';
11633
11634/** Used to match property names within property paths. */
11635var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
11636 reIsPlainProp = /^\w*$/,
11637 reLeadingDot = /^\./,
11638 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
11639
11640/**
11641 * Used to match `RegExp`
11642 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
11643 */
11644var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
11645
11646/** Used to match backslashes in property paths. */
11647var reEscapeChar = /\\(\\)?/g;
11648
11649/** Used to detect host constructors (Safari). */
11650var reIsHostCtor = /^\[object .+?Constructor\]$/;
11651
11652/** Detect free variable `global` from Node.js. */
11653var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
11654
11655/** Detect free variable `self`. */
11656var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
11657
11658/** Used as a reference to the global object. */
11659var root = freeGlobal || freeSelf || Function('return this')();
11660
11661/**
11662 * Gets the value at `key` of `object`.
11663 *
11664 * @private
11665 * @param {Object} [object] The object to query.
11666 * @param {string} key The key of the property to get.
11667 * @returns {*} Returns the property value.
11668 */
11669function getValue(object, key) {
11670 return object == null ? undefined : object[key];
11671}
11672
11673/**
11674 * Checks if `value` is a host object in IE < 9.
11675 *
11676 * @private
11677 * @param {*} value The value to check.
11678 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
11679 */
11680function isHostObject(value) {
11681 // Many host objects are `Object` objects that can coerce to strings
11682 // despite having improperly defined `toString` methods.
11683 var result = false;
11684 if (value != null && typeof value.toString != 'function') {
11685 try {
11686 result = !!(value + '');
11687 } catch (e) {}
11688 }
11689 return result;
11690}
11691
11692/** Used for built-in method references. */
11693var arrayProto = Array.prototype,
11694 funcProto = Function.prototype,
11695 objectProto = Object.prototype;
11696
11697/** Used to detect overreaching core-js shims. */
11698var coreJsData = root['__core-js_shared__'];
11699
11700/** Used to detect methods masquerading as native. */
11701var maskSrcKey = (function() {
11702 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
11703 return uid ? ('Symbol(src)_1.' + uid) : '';
11704}());
11705
11706/** Used to resolve the decompiled source of functions. */
11707var funcToString = funcProto.toString;
11708
11709/** Used to check objects for own properties. */
11710var hasOwnProperty = objectProto.hasOwnProperty;
11711
11712/**
11713 * Used to resolve the
11714 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11715 * of values.
11716 */
11717var objectToString = objectProto.toString;
11718
11719/** Used to detect if a method is native. */
11720var reIsNative = RegExp('^' +
11721 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
11722 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
11723);
11724
11725/** Built-in value references. */
11726var Symbol = root.Symbol,
11727 splice = arrayProto.splice;
11728
11729/* Built-in method references that are verified to be native. */
11730var Map = getNative(root, 'Map'),
11731 nativeCreate = getNative(Object, 'create');
11732
11733/** Used to convert symbols to primitives and strings. */
11734var symbolProto = Symbol ? Symbol.prototype : undefined,
11735 symbolToString = symbolProto ? symbolProto.toString : undefined;
11736
11737/**
11738 * Creates a hash object.
11739 *
11740 * @private
11741 * @constructor
11742 * @param {Array} [entries] The key-value pairs to cache.
11743 */
11744function Hash(entries) {
11745 var index = -1,
11746 length = entries ? entries.length : 0;
11747
11748 this.clear();
11749 while (++index < length) {
11750 var entry = entries[index];
11751 this.set(entry[0], entry[1]);
11752 }
11753}
11754
11755/**
11756 * Removes all key-value entries from the hash.
11757 *
11758 * @private
11759 * @name clear
11760 * @memberOf Hash
11761 */
11762function hashClear() {
11763 this.__data__ = nativeCreate ? nativeCreate(null) : {};
11764}
11765
11766/**
11767 * Removes `key` and its value from the hash.
11768 *
11769 * @private
11770 * @name delete
11771 * @memberOf Hash
11772 * @param {Object} hash The hash to modify.
11773 * @param {string} key The key of the value to remove.
11774 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11775 */
11776function hashDelete(key) {
11777 return this.has(key) && delete this.__data__[key];
11778}
11779
11780/**
11781 * Gets the hash value for `key`.
11782 *
11783 * @private
11784 * @name get
11785 * @memberOf Hash
11786 * @param {string} key The key of the value to get.
11787 * @returns {*} Returns the entry value.
11788 */
11789function hashGet(key) {
11790 var data = this.__data__;
11791 if (nativeCreate) {
11792 var result = data[key];
11793 return result === HASH_UNDEFINED ? undefined : result;
11794 }
11795 return hasOwnProperty.call(data, key) ? data[key] : undefined;
11796}
11797
11798/**
11799 * Checks if a hash value for `key` exists.
11800 *
11801 * @private
11802 * @name has
11803 * @memberOf Hash
11804 * @param {string} key The key of the entry to check.
11805 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11806 */
11807function hashHas(key) {
11808 var data = this.__data__;
11809 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
11810}
11811
11812/**
11813 * Sets the hash `key` to `value`.
11814 *
11815 * @private
11816 * @name set
11817 * @memberOf Hash
11818 * @param {string} key The key of the value to set.
11819 * @param {*} value The value to set.
11820 * @returns {Object} Returns the hash instance.
11821 */
11822function hashSet(key, value) {
11823 var data = this.__data__;
11824 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
11825 return this;
11826}
11827
11828// Add methods to `Hash`.
11829Hash.prototype.clear = hashClear;
11830Hash.prototype['delete'] = hashDelete;
11831Hash.prototype.get = hashGet;
11832Hash.prototype.has = hashHas;
11833Hash.prototype.set = hashSet;
11834
11835/**
11836 * Creates an list cache object.
11837 *
11838 * @private
11839 * @constructor
11840 * @param {Array} [entries] The key-value pairs to cache.
11841 */
11842function ListCache(entries) {
11843 var index = -1,
11844 length = entries ? entries.length : 0;
11845
11846 this.clear();
11847 while (++index < length) {
11848 var entry = entries[index];
11849 this.set(entry[0], entry[1]);
11850 }
11851}
11852
11853/**
11854 * Removes all key-value entries from the list cache.
11855 *
11856 * @private
11857 * @name clear
11858 * @memberOf ListCache
11859 */
11860function listCacheClear() {
11861 this.__data__ = [];
11862}
11863
11864/**
11865 * Removes `key` and its value from the list cache.
11866 *
11867 * @private
11868 * @name delete
11869 * @memberOf ListCache
11870 * @param {string} key The key of the value to remove.
11871 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11872 */
11873function listCacheDelete(key) {
11874 var data = this.__data__,
11875 index = assocIndexOf(data, key);
11876
11877 if (index < 0) {
11878 return false;
11879 }
11880 var lastIndex = data.length - 1;
11881 if (index == lastIndex) {
11882 data.pop();
11883 } else {
11884 splice.call(data, index, 1);
11885 }
11886 return true;
11887}
11888
11889/**
11890 * Gets the list cache value for `key`.
11891 *
11892 * @private
11893 * @name get
11894 * @memberOf ListCache
11895 * @param {string} key The key of the value to get.
11896 * @returns {*} Returns the entry value.
11897 */
11898function listCacheGet(key) {
11899 var data = this.__data__,
11900 index = assocIndexOf(data, key);
11901
11902 return index < 0 ? undefined : data[index][1];
11903}
11904
11905/**
11906 * Checks if a list cache value for `key` exists.
11907 *
11908 * @private
11909 * @name has
11910 * @memberOf ListCache
11911 * @param {string} key The key of the entry to check.
11912 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11913 */
11914function listCacheHas(key) {
11915 return assocIndexOf(this.__data__, key) > -1;
11916}
11917
11918/**
11919 * Sets the list cache `key` to `value`.
11920 *
11921 * @private
11922 * @name set
11923 * @memberOf ListCache
11924 * @param {string} key The key of the value to set.
11925 * @param {*} value The value to set.
11926 * @returns {Object} Returns the list cache instance.
11927 */
11928function listCacheSet(key, value) {
11929 var data = this.__data__,
11930 index = assocIndexOf(data, key);
11931
11932 if (index < 0) {
11933 data.push([key, value]);
11934 } else {
11935 data[index][1] = value;
11936 }
11937 return this;
11938}
11939
11940// Add methods to `ListCache`.
11941ListCache.prototype.clear = listCacheClear;
11942ListCache.prototype['delete'] = listCacheDelete;
11943ListCache.prototype.get = listCacheGet;
11944ListCache.prototype.has = listCacheHas;
11945ListCache.prototype.set = listCacheSet;
11946
11947/**
11948 * Creates a map cache object to store key-value pairs.
11949 *
11950 * @private
11951 * @constructor
11952 * @param {Array} [entries] The key-value pairs to cache.
11953 */
11954function MapCache(entries) {
11955 var index = -1,
11956 length = entries ? entries.length : 0;
11957
11958 this.clear();
11959 while (++index < length) {
11960 var entry = entries[index];
11961 this.set(entry[0], entry[1]);
11962 }
11963}
11964
11965/**
11966 * Removes all key-value entries from the map.
11967 *
11968 * @private
11969 * @name clear
11970 * @memberOf MapCache
11971 */
11972function mapCacheClear() {
11973 this.__data__ = {
11974 'hash': new Hash,
11975 'map': new (Map || ListCache),
11976 'string': new Hash
11977 };
11978}
11979
11980/**
11981 * Removes `key` and its value from the map.
11982 *
11983 * @private
11984 * @name delete
11985 * @memberOf MapCache
11986 * @param {string} key The key of the value to remove.
11987 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11988 */
11989function mapCacheDelete(key) {
11990 return getMapData(this, key)['delete'](key);
11991}
11992
11993/**
11994 * Gets the map value for `key`.
11995 *
11996 * @private
11997 * @name get
11998 * @memberOf MapCache
11999 * @param {string} key The key of the value to get.
12000 * @returns {*} Returns the entry value.
12001 */
12002function mapCacheGet(key) {
12003 return getMapData(this, key).get(key);
12004}
12005
12006/**
12007 * Checks if a map value for `key` exists.
12008 *
12009 * @private
12010 * @name has
12011 * @memberOf MapCache
12012 * @param {string} key The key of the entry to check.
12013 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12014 */
12015function mapCacheHas(key) {
12016 return getMapData(this, key).has(key);
12017}
12018
12019/**
12020 * Sets the map `key` to `value`.
12021 *
12022 * @private
12023 * @name set
12024 * @memberOf MapCache
12025 * @param {string} key The key of the value to set.
12026 * @param {*} value The value to set.
12027 * @returns {Object} Returns the map cache instance.
12028 */
12029function mapCacheSet(key, value) {
12030 getMapData(this, key).set(key, value);
12031 return this;
12032}
12033
12034// Add methods to `MapCache`.
12035MapCache.prototype.clear = mapCacheClear;
12036MapCache.prototype['delete'] = mapCacheDelete;
12037MapCache.prototype.get = mapCacheGet;
12038MapCache.prototype.has = mapCacheHas;
12039MapCache.prototype.set = mapCacheSet;
12040
12041/**
12042 * Gets the index at which the `key` is found in `array` of key-value pairs.
12043 *
12044 * @private
12045 * @param {Array} array The array to inspect.
12046 * @param {*} key The key to search for.
12047 * @returns {number} Returns the index of the matched value, else `-1`.
12048 */
12049function assocIndexOf(array, key) {
12050 var length = array.length;
12051 while (length--) {
12052 if (eq(array[length][0], key)) {
12053 return length;
12054 }
12055 }
12056 return -1;
12057}
12058
12059/**
12060 * The base implementation of `_.get` without support for default values.
12061 *
12062 * @private
12063 * @param {Object} object The object to query.
12064 * @param {Array|string} path The path of the property to get.
12065 * @returns {*} Returns the resolved value.
12066 */
12067function baseGet(object, path) {
12068 path = isKey(path, object) ? [path] : castPath(path);
12069
12070 var index = 0,
12071 length = path.length;
12072
12073 while (object != null && index < length) {
12074 object = object[toKey(path[index++])];
12075 }
12076 return (index && index == length) ? object : undefined;
12077}
12078
12079/**
12080 * The base implementation of `_.isNative` without bad shim checks.
12081 *
12082 * @private
12083 * @param {*} value The value to check.
12084 * @returns {boolean} Returns `true` if `value` is a native function,
12085 * else `false`.
12086 */
12087function baseIsNative(value) {
12088 if (!isObject(value) || isMasked(value)) {
12089 return false;
12090 }
12091 var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
12092 return pattern.test(toSource(value));
12093}
12094
12095/**
12096 * The base implementation of `_.toString` which doesn't convert nullish
12097 * values to empty strings.
12098 *
12099 * @private
12100 * @param {*} value The value to process.
12101 * @returns {string} Returns the string.
12102 */
12103function baseToString(value) {
12104 // Exit early for strings to avoid a performance hit in some environments.
12105 if (typeof value == 'string') {
12106 return value;
12107 }
12108 if (isSymbol(value)) {
12109 return symbolToString ? symbolToString.call(value) : '';
12110 }
12111 var result = (value + '');
12112 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
12113}
12114
12115/**
12116 * Casts `value` to a path array if it's not one.
12117 *
12118 * @private
12119 * @param {*} value The value to inspect.
12120 * @returns {Array} Returns the cast property path array.
12121 */
12122function castPath(value) {
12123 return isArray(value) ? value : stringToPath(value);
12124}
12125
12126/**
12127 * Gets the data for `map`.
12128 *
12129 * @private
12130 * @param {Object} map The map to query.
12131 * @param {string} key The reference key.
12132 * @returns {*} Returns the map data.
12133 */
12134function getMapData(map, key) {
12135 var data = map.__data__;
12136 return isKeyable(key)
12137 ? data[typeof key == 'string' ? 'string' : 'hash']
12138 : data.map;
12139}
12140
12141/**
12142 * Gets the native function at `key` of `object`.
12143 *
12144 * @private
12145 * @param {Object} object The object to query.
12146 * @param {string} key The key of the method to get.
12147 * @returns {*} Returns the function if it's native, else `undefined`.
12148 */
12149function getNative(object, key) {
12150 var value = getValue(object, key);
12151 return baseIsNative(value) ? value : undefined;
12152}
12153
12154/**
12155 * Checks if `value` is a property name and not a property path.
12156 *
12157 * @private
12158 * @param {*} value The value to check.
12159 * @param {Object} [object] The object to query keys on.
12160 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
12161 */
12162function isKey(value, object) {
12163 if (isArray(value)) {
12164 return false;
12165 }
12166 var type = typeof value;
12167 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
12168 value == null || isSymbol(value)) {
12169 return true;
12170 }
12171 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
12172 (object != null && value in Object(object));
12173}
12174
12175/**
12176 * Checks if `value` is suitable for use as unique object key.
12177 *
12178 * @private
12179 * @param {*} value The value to check.
12180 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
12181 */
12182function isKeyable(value) {
12183 var type = typeof value;
12184 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
12185 ? (value !== '__proto__')
12186 : (value === null);
12187}
12188
12189/**
12190 * Checks if `func` has its source masked.
12191 *
12192 * @private
12193 * @param {Function} func The function to check.
12194 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
12195 */
12196function isMasked(func) {
12197 return !!maskSrcKey && (maskSrcKey in func);
12198}
12199
12200/**
12201 * Converts `string` to a property path array.
12202 *
12203 * @private
12204 * @param {string} string The string to convert.
12205 * @returns {Array} Returns the property path array.
12206 */
12207var stringToPath = memoize(function(string) {
12208 string = toString(string);
12209
12210 var result = [];
12211 if (reLeadingDot.test(string)) {
12212 result.push('');
12213 }
12214 string.replace(rePropName, function(match, number, quote, string) {
12215 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
12216 });
12217 return result;
12218});
12219
12220/**
12221 * Converts `value` to a string key if it's not a string or symbol.
12222 *
12223 * @private
12224 * @param {*} value The value to inspect.
12225 * @returns {string|symbol} Returns the key.
12226 */
12227function toKey(value) {
12228 if (typeof value == 'string' || isSymbol(value)) {
12229 return value;
12230 }
12231 var result = (value + '');
12232 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
12233}
12234
12235/**
12236 * Converts `func` to its source code.
12237 *
12238 * @private
12239 * @param {Function} func The function to process.
12240 * @returns {string} Returns the source code.
12241 */
12242function toSource(func) {
12243 if (func != null) {
12244 try {
12245 return funcToString.call(func);
12246 } catch (e) {}
12247 try {
12248 return (func + '');
12249 } catch (e) {}
12250 }
12251 return '';
12252}
12253
12254/**
12255 * Creates a function that memoizes the result of `func`. If `resolver` is
12256 * provided, it determines the cache key for storing the result based on the
12257 * arguments provided to the memoized function. By default, the first argument
12258 * provided to the memoized function is used as the map cache key. The `func`
12259 * is invoked with the `this` binding of the memoized function.
12260 *
12261 * **Note:** The cache is exposed as the `cache` property on the memoized
12262 * function. Its creation may be customized by replacing the `_.memoize.Cache`
12263 * constructor with one whose instances implement the
12264 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
12265 * method interface of `delete`, `get`, `has`, and `set`.
12266 *
12267 * @static
12268 * @memberOf _
12269 * @since 0.1.0
12270 * @category Function
12271 * @param {Function} func The function to have its output memoized.
12272 * @param {Function} [resolver] The function to resolve the cache key.
12273 * @returns {Function} Returns the new memoized function.
12274 * @example
12275 *
12276 * var object = { 'a': 1, 'b': 2 };
12277 * var other = { 'c': 3, 'd': 4 };
12278 *
12279 * var values = _.memoize(_.values);
12280 * values(object);
12281 * // => [1, 2]
12282 *
12283 * values(other);
12284 * // => [3, 4]
12285 *
12286 * object.a = 2;
12287 * values(object);
12288 * // => [1, 2]
12289 *
12290 * // Modify the result cache.
12291 * values.cache.set(object, ['a', 'b']);
12292 * values(object);
12293 * // => ['a', 'b']
12294 *
12295 * // Replace `_.memoize.Cache`.
12296 * _.memoize.Cache = WeakMap;
12297 */
12298function memoize(func, resolver) {
12299 if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
12300 throw new TypeError(FUNC_ERROR_TEXT);
12301 }
12302 var memoized = function() {
12303 var args = arguments,
12304 key = resolver ? resolver.apply(this, args) : args[0],
12305 cache = memoized.cache;
12306
12307 if (cache.has(key)) {
12308 return cache.get(key);
12309 }
12310 var result = func.apply(this, args);
12311 memoized.cache = cache.set(key, result);
12312 return result;
12313 };
12314 memoized.cache = new (memoize.Cache || MapCache);
12315 return memoized;
12316}
12317
12318// Assign cache to `_.memoize`.
12319memoize.Cache = MapCache;
12320
12321/**
12322 * Performs a
12323 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
12324 * comparison between two values to determine if they are equivalent.
12325 *
12326 * @static
12327 * @memberOf _
12328 * @since 4.0.0
12329 * @category Lang
12330 * @param {*} value The value to compare.
12331 * @param {*} other The other value to compare.
12332 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
12333 * @example
12334 *
12335 * var object = { 'a': 1 };
12336 * var other = { 'a': 1 };
12337 *
12338 * _.eq(object, object);
12339 * // => true
12340 *
12341 * _.eq(object, other);
12342 * // => false
12343 *
12344 * _.eq('a', 'a');
12345 * // => true
12346 *
12347 * _.eq('a', Object('a'));
12348 * // => false
12349 *
12350 * _.eq(NaN, NaN);
12351 * // => true
12352 */
12353function eq(value, other) {
12354 return value === other || (value !== value && other !== other);
12355}
12356
12357/**
12358 * Checks if `value` is classified as an `Array` object.
12359 *
12360 * @static
12361 * @memberOf _
12362 * @since 0.1.0
12363 * @category Lang
12364 * @param {*} value The value to check.
12365 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
12366 * @example
12367 *
12368 * _.isArray([1, 2, 3]);
12369 * // => true
12370 *
12371 * _.isArray(document.body.children);
12372 * // => false
12373 *
12374 * _.isArray('abc');
12375 * // => false
12376 *
12377 * _.isArray(_.noop);
12378 * // => false
12379 */
12380var isArray = Array.isArray;
12381
12382/**
12383 * Checks if `value` is classified as a `Function` object.
12384 *
12385 * @static
12386 * @memberOf _
12387 * @since 0.1.0
12388 * @category Lang
12389 * @param {*} value The value to check.
12390 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
12391 * @example
12392 *
12393 * _.isFunction(_);
12394 * // => true
12395 *
12396 * _.isFunction(/abc/);
12397 * // => false
12398 */
12399function isFunction(value) {
12400 // The use of `Object#toString` avoids issues with the `typeof` operator
12401 // in Safari 8-9 which returns 'object' for typed array and other constructors.
12402 var tag = isObject(value) ? objectToString.call(value) : '';
12403 return tag == funcTag || tag == genTag;
12404}
12405
12406/**
12407 * Checks if `value` is the
12408 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
12409 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
12410 *
12411 * @static
12412 * @memberOf _
12413 * @since 0.1.0
12414 * @category Lang
12415 * @param {*} value The value to check.
12416 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
12417 * @example
12418 *
12419 * _.isObject({});
12420 * // => true
12421 *
12422 * _.isObject([1, 2, 3]);
12423 * // => true
12424 *
12425 * _.isObject(_.noop);
12426 * // => true
12427 *
12428 * _.isObject(null);
12429 * // => false
12430 */
12431function isObject(value) {
12432 var type = typeof value;
12433 return !!value && (type == 'object' || type == 'function');
12434}
12435
12436/**
12437 * Checks if `value` is object-like. A value is object-like if it's not `null`
12438 * and has a `typeof` result of "object".
12439 *
12440 * @static
12441 * @memberOf _
12442 * @since 4.0.0
12443 * @category Lang
12444 * @param {*} value The value to check.
12445 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
12446 * @example
12447 *
12448 * _.isObjectLike({});
12449 * // => true
12450 *
12451 * _.isObjectLike([1, 2, 3]);
12452 * // => true
12453 *
12454 * _.isObjectLike(_.noop);
12455 * // => false
12456 *
12457 * _.isObjectLike(null);
12458 * // => false
12459 */
12460function isObjectLike(value) {
12461 return !!value && typeof value == 'object';
12462}
12463
12464/**
12465 * Checks if `value` is classified as a `Symbol` primitive or object.
12466 *
12467 * @static
12468 * @memberOf _
12469 * @since 4.0.0
12470 * @category Lang
12471 * @param {*} value The value to check.
12472 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12473 * @example
12474 *
12475 * _.isSymbol(Symbol.iterator);
12476 * // => true
12477 *
12478 * _.isSymbol('abc');
12479 * // => false
12480 */
12481function isSymbol(value) {
12482 return typeof value == 'symbol' ||
12483 (isObjectLike(value) && objectToString.call(value) == symbolTag);
12484}
12485
12486/**
12487 * Converts `value` to a string. An empty string is returned for `null`
12488 * and `undefined` values. The sign of `-0` is preserved.
12489 *
12490 * @static
12491 * @memberOf _
12492 * @since 4.0.0
12493 * @category Lang
12494 * @param {*} value The value to process.
12495 * @returns {string} Returns the string.
12496 * @example
12497 *
12498 * _.toString(null);
12499 * // => ''
12500 *
12501 * _.toString(-0);
12502 * // => '-0'
12503 *
12504 * _.toString([1, 2, 3]);
12505 * // => '1,2,3'
12506 */
12507function toString(value) {
12508 return value == null ? '' : baseToString(value);
12509}
12510
12511/**
12512 * Gets the value at `path` of `object`. If the resolved value is
12513 * `undefined`, the `defaultValue` is returned in its place.
12514 *
12515 * @static
12516 * @memberOf _
12517 * @since 3.7.0
12518 * @category Object
12519 * @param {Object} object The object to query.
12520 * @param {Array|string} path The path of the property to get.
12521 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
12522 * @returns {*} Returns the resolved value.
12523 * @example
12524 *
12525 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
12526 *
12527 * _.get(object, 'a[0].b.c');
12528 * // => 3
12529 *
12530 * _.get(object, ['a', '0', 'b', 'c']);
12531 * // => 3
12532 *
12533 * _.get(object, 'a.b.c', 'default');
12534 * // => 'default'
12535 */
12536function get(object, path, defaultValue) {
12537 var result = object == null ? undefined : baseGet(object, path);
12538 return result === undefined ? defaultValue : result;
12539}
12540
12541module.exports = get;
12542
12543}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
12544
12545},{}],121:[function(require,module,exports){
12546(function (global){
12547/**
12548 * Lodash (Custom Build) <https://lodash.com/>
12549 * Build: `lodash modularize exports="npm" -o ./`
12550 * Copyright JS Foundation and other contributors <https://js.foundation/>
12551 * Released under MIT license <https://lodash.com/license>
12552 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
12553 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12554 */
12555
12556/** Used as the size to enable large array optimizations. */
12557var LARGE_ARRAY_SIZE = 200;
12558
12559/** Used to stand-in for `undefined` hash values. */
12560var HASH_UNDEFINED = '__lodash_hash_undefined__';
12561
12562/** Used to compose bitmasks for value comparisons. */
12563var COMPARE_PARTIAL_FLAG = 1,
12564 COMPARE_UNORDERED_FLAG = 2;
12565
12566/** Used as references for various `Number` constants. */
12567var MAX_SAFE_INTEGER = 9007199254740991;
12568
12569/** `Object#toString` result references. */
12570var argsTag = '[object Arguments]',
12571 arrayTag = '[object Array]',
12572 asyncTag = '[object AsyncFunction]',
12573 boolTag = '[object Boolean]',
12574 dateTag = '[object Date]',
12575 errorTag = '[object Error]',
12576 funcTag = '[object Function]',
12577 genTag = '[object GeneratorFunction]',
12578 mapTag = '[object Map]',
12579 numberTag = '[object Number]',
12580 nullTag = '[object Null]',
12581 objectTag = '[object Object]',
12582 promiseTag = '[object Promise]',
12583 proxyTag = '[object Proxy]',
12584 regexpTag = '[object RegExp]',
12585 setTag = '[object Set]',
12586 stringTag = '[object String]',
12587 symbolTag = '[object Symbol]',
12588 undefinedTag = '[object Undefined]',
12589 weakMapTag = '[object WeakMap]';
12590
12591var arrayBufferTag = '[object ArrayBuffer]',
12592 dataViewTag = '[object DataView]',
12593 float32Tag = '[object Float32Array]',
12594 float64Tag = '[object Float64Array]',
12595 int8Tag = '[object Int8Array]',
12596 int16Tag = '[object Int16Array]',
12597 int32Tag = '[object Int32Array]',
12598 uint8Tag = '[object Uint8Array]',
12599 uint8ClampedTag = '[object Uint8ClampedArray]',
12600 uint16Tag = '[object Uint16Array]',
12601 uint32Tag = '[object Uint32Array]';
12602
12603/**
12604 * Used to match `RegExp`
12605 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
12606 */
12607var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
12608
12609/** Used to detect host constructors (Safari). */
12610var reIsHostCtor = /^\[object .+?Constructor\]$/;
12611
12612/** Used to detect unsigned integer values. */
12613var reIsUint = /^(?:0|[1-9]\d*)$/;
12614
12615/** Used to identify `toStringTag` values of typed arrays. */
12616var typedArrayTags = {};
12617typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
12618typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
12619typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
12620typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
12621typedArrayTags[uint32Tag] = true;
12622typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
12623typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
12624typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
12625typedArrayTags[errorTag] = typedArrayTags[funcTag] =
12626typedArrayTags[mapTag] = typedArrayTags[numberTag] =
12627typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
12628typedArrayTags[setTag] = typedArrayTags[stringTag] =
12629typedArrayTags[weakMapTag] = false;
12630
12631/** Detect free variable `global` from Node.js. */
12632var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
12633
12634/** Detect free variable `self`. */
12635var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
12636
12637/** Used as a reference to the global object. */
12638var root = freeGlobal || freeSelf || Function('return this')();
12639
12640/** Detect free variable `exports`. */
12641var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
12642
12643/** Detect free variable `module`. */
12644var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
12645
12646/** Detect the popular CommonJS extension `module.exports`. */
12647var moduleExports = freeModule && freeModule.exports === freeExports;
12648
12649/** Detect free variable `process` from Node.js. */
12650var freeProcess = moduleExports && freeGlobal.process;
12651
12652/** Used to access faster Node.js helpers. */
12653var nodeUtil = (function() {
12654 try {
12655 return freeProcess && freeProcess.binding && freeProcess.binding('util');
12656 } catch (e) {}
12657}());
12658
12659/* Node.js helper references. */
12660var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
12661
12662/**
12663 * A specialized version of `_.filter` for arrays without support for
12664 * iteratee shorthands.
12665 *
12666 * @private
12667 * @param {Array} [array] The array to iterate over.
12668 * @param {Function} predicate The function invoked per iteration.
12669 * @returns {Array} Returns the new filtered array.
12670 */
12671function arrayFilter(array, predicate) {
12672 var index = -1,
12673 length = array == null ? 0 : array.length,
12674 resIndex = 0,
12675 result = [];
12676
12677 while (++index < length) {
12678 var value = array[index];
12679 if (predicate(value, index, array)) {
12680 result[resIndex++] = value;
12681 }
12682 }
12683 return result;
12684}
12685
12686/**
12687 * Appends the elements of `values` to `array`.
12688 *
12689 * @private
12690 * @param {Array} array The array to modify.
12691 * @param {Array} values The values to append.
12692 * @returns {Array} Returns `array`.
12693 */
12694function arrayPush(array, values) {
12695 var index = -1,
12696 length = values.length,
12697 offset = array.length;
12698
12699 while (++index < length) {
12700 array[offset + index] = values[index];
12701 }
12702 return array;
12703}
12704
12705/**
12706 * A specialized version of `_.some` for arrays without support for iteratee
12707 * shorthands.
12708 *
12709 * @private
12710 * @param {Array} [array] The array to iterate over.
12711 * @param {Function} predicate The function invoked per iteration.
12712 * @returns {boolean} Returns `true` if any element passes the predicate check,
12713 * else `false`.
12714 */
12715function arraySome(array, predicate) {
12716 var index = -1,
12717 length = array == null ? 0 : array.length;
12718
12719 while (++index < length) {
12720 if (predicate(array[index], index, array)) {
12721 return true;
12722 }
12723 }
12724 return false;
12725}
12726
12727/**
12728 * The base implementation of `_.times` without support for iteratee shorthands
12729 * or max array length checks.
12730 *
12731 * @private
12732 * @param {number} n The number of times to invoke `iteratee`.
12733 * @param {Function} iteratee The function invoked per iteration.
12734 * @returns {Array} Returns the array of results.
12735 */
12736function baseTimes(n, iteratee) {
12737 var index = -1,
12738 result = Array(n);
12739
12740 while (++index < n) {
12741 result[index] = iteratee(index);
12742 }
12743 return result;
12744}
12745
12746/**
12747 * The base implementation of `_.unary` without support for storing metadata.
12748 *
12749 * @private
12750 * @param {Function} func The function to cap arguments for.
12751 * @returns {Function} Returns the new capped function.
12752 */
12753function baseUnary(func) {
12754 return function(value) {
12755 return func(value);
12756 };
12757}
12758
12759/**
12760 * Checks if a `cache` value for `key` exists.
12761 *
12762 * @private
12763 * @param {Object} cache The cache to query.
12764 * @param {string} key The key of the entry to check.
12765 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12766 */
12767function cacheHas(cache, key) {
12768 return cache.has(key);
12769}
12770
12771/**
12772 * Gets the value at `key` of `object`.
12773 *
12774 * @private
12775 * @param {Object} [object] The object to query.
12776 * @param {string} key The key of the property to get.
12777 * @returns {*} Returns the property value.
12778 */
12779function getValue(object, key) {
12780 return object == null ? undefined : object[key];
12781}
12782
12783/**
12784 * Converts `map` to its key-value pairs.
12785 *
12786 * @private
12787 * @param {Object} map The map to convert.
12788 * @returns {Array} Returns the key-value pairs.
12789 */
12790function mapToArray(map) {
12791 var index = -1,
12792 result = Array(map.size);
12793
12794 map.forEach(function(value, key) {
12795 result[++index] = [key, value];
12796 });
12797 return result;
12798}
12799
12800/**
12801 * Creates a unary function that invokes `func` with its argument transformed.
12802 *
12803 * @private
12804 * @param {Function} func The function to wrap.
12805 * @param {Function} transform The argument transform.
12806 * @returns {Function} Returns the new function.
12807 */
12808function overArg(func, transform) {
12809 return function(arg) {
12810 return func(transform(arg));
12811 };
12812}
12813
12814/**
12815 * Converts `set` to an array of its values.
12816 *
12817 * @private
12818 * @param {Object} set The set to convert.
12819 * @returns {Array} Returns the values.
12820 */
12821function setToArray(set) {
12822 var index = -1,
12823 result = Array(set.size);
12824
12825 set.forEach(function(value) {
12826 result[++index] = value;
12827 });
12828 return result;
12829}
12830
12831/** Used for built-in method references. */
12832var arrayProto = Array.prototype,
12833 funcProto = Function.prototype,
12834 objectProto = Object.prototype;
12835
12836/** Used to detect overreaching core-js shims. */
12837var coreJsData = root['__core-js_shared__'];
12838
12839/** Used to resolve the decompiled source of functions. */
12840var funcToString = funcProto.toString;
12841
12842/** Used to check objects for own properties. */
12843var hasOwnProperty = objectProto.hasOwnProperty;
12844
12845/** Used to detect methods masquerading as native. */
12846var maskSrcKey = (function() {
12847 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
12848 return uid ? ('Symbol(src)_1.' + uid) : '';
12849}());
12850
12851/**
12852 * Used to resolve the
12853 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
12854 * of values.
12855 */
12856var nativeObjectToString = objectProto.toString;
12857
12858/** Used to detect if a method is native. */
12859var reIsNative = RegExp('^' +
12860 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
12861 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
12862);
12863
12864/** Built-in value references. */
12865var Buffer = moduleExports ? root.Buffer : undefined,
12866 Symbol = root.Symbol,
12867 Uint8Array = root.Uint8Array,
12868 propertyIsEnumerable = objectProto.propertyIsEnumerable,
12869 splice = arrayProto.splice,
12870 symToStringTag = Symbol ? Symbol.toStringTag : undefined;
12871
12872/* Built-in method references for those with the same name as other `lodash` methods. */
12873var nativeGetSymbols = Object.getOwnPropertySymbols,
12874 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
12875 nativeKeys = overArg(Object.keys, Object);
12876
12877/* Built-in method references that are verified to be native. */
12878var DataView = getNative(root, 'DataView'),
12879 Map = getNative(root, 'Map'),
12880 Promise = getNative(root, 'Promise'),
12881 Set = getNative(root, 'Set'),
12882 WeakMap = getNative(root, 'WeakMap'),
12883 nativeCreate = getNative(Object, 'create');
12884
12885/** Used to detect maps, sets, and weakmaps. */
12886var dataViewCtorString = toSource(DataView),
12887 mapCtorString = toSource(Map),
12888 promiseCtorString = toSource(Promise),
12889 setCtorString = toSource(Set),
12890 weakMapCtorString = toSource(WeakMap);
12891
12892/** Used to convert symbols to primitives and strings. */
12893var symbolProto = Symbol ? Symbol.prototype : undefined,
12894 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
12895
12896/**
12897 * Creates a hash object.
12898 *
12899 * @private
12900 * @constructor
12901 * @param {Array} [entries] The key-value pairs to cache.
12902 */
12903function Hash(entries) {
12904 var index = -1,
12905 length = entries == null ? 0 : entries.length;
12906
12907 this.clear();
12908 while (++index < length) {
12909 var entry = entries[index];
12910 this.set(entry[0], entry[1]);
12911 }
12912}
12913
12914/**
12915 * Removes all key-value entries from the hash.
12916 *
12917 * @private
12918 * @name clear
12919 * @memberOf Hash
12920 */
12921function hashClear() {
12922 this.__data__ = nativeCreate ? nativeCreate(null) : {};
12923 this.size = 0;
12924}
12925
12926/**
12927 * Removes `key` and its value from the hash.
12928 *
12929 * @private
12930 * @name delete
12931 * @memberOf Hash
12932 * @param {Object} hash The hash to modify.
12933 * @param {string} key The key of the value to remove.
12934 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
12935 */
12936function hashDelete(key) {
12937 var result = this.has(key) && delete this.__data__[key];
12938 this.size -= result ? 1 : 0;
12939 return result;
12940}
12941
12942/**
12943 * Gets the hash value for `key`.
12944 *
12945 * @private
12946 * @name get
12947 * @memberOf Hash
12948 * @param {string} key The key of the value to get.
12949 * @returns {*} Returns the entry value.
12950 */
12951function hashGet(key) {
12952 var data = this.__data__;
12953 if (nativeCreate) {
12954 var result = data[key];
12955 return result === HASH_UNDEFINED ? undefined : result;
12956 }
12957 return hasOwnProperty.call(data, key) ? data[key] : undefined;
12958}
12959
12960/**
12961 * Checks if a hash value for `key` exists.
12962 *
12963 * @private
12964 * @name has
12965 * @memberOf Hash
12966 * @param {string} key The key of the entry to check.
12967 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12968 */
12969function hashHas(key) {
12970 var data = this.__data__;
12971 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
12972}
12973
12974/**
12975 * Sets the hash `key` to `value`.
12976 *
12977 * @private
12978 * @name set
12979 * @memberOf Hash
12980 * @param {string} key The key of the value to set.
12981 * @param {*} value The value to set.
12982 * @returns {Object} Returns the hash instance.
12983 */
12984function hashSet(key, value) {
12985 var data = this.__data__;
12986 this.size += this.has(key) ? 0 : 1;
12987 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
12988 return this;
12989}
12990
12991// Add methods to `Hash`.
12992Hash.prototype.clear = hashClear;
12993Hash.prototype['delete'] = hashDelete;
12994Hash.prototype.get = hashGet;
12995Hash.prototype.has = hashHas;
12996Hash.prototype.set = hashSet;
12997
12998/**
12999 * Creates an list cache object.
13000 *
13001 * @private
13002 * @constructor
13003 * @param {Array} [entries] The key-value pairs to cache.
13004 */
13005function ListCache(entries) {
13006 var index = -1,
13007 length = entries == null ? 0 : entries.length;
13008
13009 this.clear();
13010 while (++index < length) {
13011 var entry = entries[index];
13012 this.set(entry[0], entry[1]);
13013 }
13014}
13015
13016/**
13017 * Removes all key-value entries from the list cache.
13018 *
13019 * @private
13020 * @name clear
13021 * @memberOf ListCache
13022 */
13023function listCacheClear() {
13024 this.__data__ = [];
13025 this.size = 0;
13026}
13027
13028/**
13029 * Removes `key` and its value from the list cache.
13030 *
13031 * @private
13032 * @name delete
13033 * @memberOf ListCache
13034 * @param {string} key The key of the value to remove.
13035 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
13036 */
13037function listCacheDelete(key) {
13038 var data = this.__data__,
13039 index = assocIndexOf(data, key);
13040
13041 if (index < 0) {
13042 return false;
13043 }
13044 var lastIndex = data.length - 1;
13045 if (index == lastIndex) {
13046 data.pop();
13047 } else {
13048 splice.call(data, index, 1);
13049 }
13050 --this.size;
13051 return true;
13052}
13053
13054/**
13055 * Gets the list cache value for `key`.
13056 *
13057 * @private
13058 * @name get
13059 * @memberOf ListCache
13060 * @param {string} key The key of the value to get.
13061 * @returns {*} Returns the entry value.
13062 */
13063function listCacheGet(key) {
13064 var data = this.__data__,
13065 index = assocIndexOf(data, key);
13066
13067 return index < 0 ? undefined : data[index][1];
13068}
13069
13070/**
13071 * Checks if a list cache value for `key` exists.
13072 *
13073 * @private
13074 * @name has
13075 * @memberOf ListCache
13076 * @param {string} key The key of the entry to check.
13077 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
13078 */
13079function listCacheHas(key) {
13080 return assocIndexOf(this.__data__, key) > -1;
13081}
13082
13083/**
13084 * Sets the list cache `key` to `value`.
13085 *
13086 * @private
13087 * @name set
13088 * @memberOf ListCache
13089 * @param {string} key The key of the value to set.
13090 * @param {*} value The value to set.
13091 * @returns {Object} Returns the list cache instance.
13092 */
13093function listCacheSet(key, value) {
13094 var data = this.__data__,
13095 index = assocIndexOf(data, key);
13096
13097 if (index < 0) {
13098 ++this.size;
13099 data.push([key, value]);
13100 } else {
13101 data[index][1] = value;
13102 }
13103 return this;
13104}
13105
13106// Add methods to `ListCache`.
13107ListCache.prototype.clear = listCacheClear;
13108ListCache.prototype['delete'] = listCacheDelete;
13109ListCache.prototype.get = listCacheGet;
13110ListCache.prototype.has = listCacheHas;
13111ListCache.prototype.set = listCacheSet;
13112
13113/**
13114 * Creates a map cache object to store key-value pairs.
13115 *
13116 * @private
13117 * @constructor
13118 * @param {Array} [entries] The key-value pairs to cache.
13119 */
13120function MapCache(entries) {
13121 var index = -1,
13122 length = entries == null ? 0 : entries.length;
13123
13124 this.clear();
13125 while (++index < length) {
13126 var entry = entries[index];
13127 this.set(entry[0], entry[1]);
13128 }
13129}
13130
13131/**
13132 * Removes all key-value entries from the map.
13133 *
13134 * @private
13135 * @name clear
13136 * @memberOf MapCache
13137 */
13138function mapCacheClear() {
13139 this.size = 0;
13140 this.__data__ = {
13141 'hash': new Hash,
13142 'map': new (Map || ListCache),
13143 'string': new Hash
13144 };
13145}
13146
13147/**
13148 * Removes `key` and its value from the map.
13149 *
13150 * @private
13151 * @name delete
13152 * @memberOf MapCache
13153 * @param {string} key The key of the value to remove.
13154 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
13155 */
13156function mapCacheDelete(key) {
13157 var result = getMapData(this, key)['delete'](key);
13158 this.size -= result ? 1 : 0;
13159 return result;
13160}
13161
13162/**
13163 * Gets the map value for `key`.
13164 *
13165 * @private
13166 * @name get
13167 * @memberOf MapCache
13168 * @param {string} key The key of the value to get.
13169 * @returns {*} Returns the entry value.
13170 */
13171function mapCacheGet(key) {
13172 return getMapData(this, key).get(key);
13173}
13174
13175/**
13176 * Checks if a map value for `key` exists.
13177 *
13178 * @private
13179 * @name has
13180 * @memberOf MapCache
13181 * @param {string} key The key of the entry to check.
13182 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
13183 */
13184function mapCacheHas(key) {
13185 return getMapData(this, key).has(key);
13186}
13187
13188/**
13189 * Sets the map `key` to `value`.
13190 *
13191 * @private
13192 * @name set
13193 * @memberOf MapCache
13194 * @param {string} key The key of the value to set.
13195 * @param {*} value The value to set.
13196 * @returns {Object} Returns the map cache instance.
13197 */
13198function mapCacheSet(key, value) {
13199 var data = getMapData(this, key),
13200 size = data.size;
13201
13202 data.set(key, value);
13203 this.size += data.size == size ? 0 : 1;
13204 return this;
13205}
13206
13207// Add methods to `MapCache`.
13208MapCache.prototype.clear = mapCacheClear;
13209MapCache.prototype['delete'] = mapCacheDelete;
13210MapCache.prototype.get = mapCacheGet;
13211MapCache.prototype.has = mapCacheHas;
13212MapCache.prototype.set = mapCacheSet;
13213
13214/**
13215 *
13216 * Creates an array cache object to store unique values.
13217 *
13218 * @private
13219 * @constructor
13220 * @param {Array} [values] The values to cache.
13221 */
13222function SetCache(values) {
13223 var index = -1,
13224 length = values == null ? 0 : values.length;
13225
13226 this.__data__ = new MapCache;
13227 while (++index < length) {
13228 this.add(values[index]);
13229 }
13230}
13231
13232/**
13233 * Adds `value` to the array cache.
13234 *
13235 * @private
13236 * @name add
13237 * @memberOf SetCache
13238 * @alias push
13239 * @param {*} value The value to cache.
13240 * @returns {Object} Returns the cache instance.
13241 */
13242function setCacheAdd(value) {
13243 this.__data__.set(value, HASH_UNDEFINED);
13244 return this;
13245}
13246
13247/**
13248 * Checks if `value` is in the array cache.
13249 *
13250 * @private
13251 * @name has
13252 * @memberOf SetCache
13253 * @param {*} value The value to search for.
13254 * @returns {number} Returns `true` if `value` is found, else `false`.
13255 */
13256function setCacheHas(value) {
13257 return this.__data__.has(value);
13258}
13259
13260// Add methods to `SetCache`.
13261SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
13262SetCache.prototype.has = setCacheHas;
13263
13264/**
13265 * Creates a stack cache object to store key-value pairs.
13266 *
13267 * @private
13268 * @constructor
13269 * @param {Array} [entries] The key-value pairs to cache.
13270 */
13271function Stack(entries) {
13272 var data = this.__data__ = new ListCache(entries);
13273 this.size = data.size;
13274}
13275
13276/**
13277 * Removes all key-value entries from the stack.
13278 *
13279 * @private
13280 * @name clear
13281 * @memberOf Stack
13282 */
13283function stackClear() {
13284 this.__data__ = new ListCache;
13285 this.size = 0;
13286}
13287
13288/**
13289 * Removes `key` and its value from the stack.
13290 *
13291 * @private
13292 * @name delete
13293 * @memberOf Stack
13294 * @param {string} key The key of the value to remove.
13295 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
13296 */
13297function stackDelete(key) {
13298 var data = this.__data__,
13299 result = data['delete'](key);
13300
13301 this.size = data.size;
13302 return result;
13303}
13304
13305/**
13306 * Gets the stack value for `key`.
13307 *
13308 * @private
13309 * @name get
13310 * @memberOf Stack
13311 * @param {string} key The key of the value to get.
13312 * @returns {*} Returns the entry value.
13313 */
13314function stackGet(key) {
13315 return this.__data__.get(key);
13316}
13317
13318/**
13319 * Checks if a stack value for `key` exists.
13320 *
13321 * @private
13322 * @name has
13323 * @memberOf Stack
13324 * @param {string} key The key of the entry to check.
13325 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
13326 */
13327function stackHas(key) {
13328 return this.__data__.has(key);
13329}
13330
13331/**
13332 * Sets the stack `key` to `value`.
13333 *
13334 * @private
13335 * @name set
13336 * @memberOf Stack
13337 * @param {string} key The key of the value to set.
13338 * @param {*} value The value to set.
13339 * @returns {Object} Returns the stack cache instance.
13340 */
13341function stackSet(key, value) {
13342 var data = this.__data__;
13343 if (data instanceof ListCache) {
13344 var pairs = data.__data__;
13345 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
13346 pairs.push([key, value]);
13347 this.size = ++data.size;
13348 return this;
13349 }
13350 data = this.__data__ = new MapCache(pairs);
13351 }
13352 data.set(key, value);
13353 this.size = data.size;
13354 return this;
13355}
13356
13357// Add methods to `Stack`.
13358Stack.prototype.clear = stackClear;
13359Stack.prototype['delete'] = stackDelete;
13360Stack.prototype.get = stackGet;
13361Stack.prototype.has = stackHas;
13362Stack.prototype.set = stackSet;
13363
13364/**
13365 * Creates an array of the enumerable property names of the array-like `value`.
13366 *
13367 * @private
13368 * @param {*} value The value to query.
13369 * @param {boolean} inherited Specify returning inherited property names.
13370 * @returns {Array} Returns the array of property names.
13371 */
13372function arrayLikeKeys(value, inherited) {
13373 var isArr = isArray(value),
13374 isArg = !isArr && isArguments(value),
13375 isBuff = !isArr && !isArg && isBuffer(value),
13376 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
13377 skipIndexes = isArr || isArg || isBuff || isType,
13378 result = skipIndexes ? baseTimes(value.length, String) : [],
13379 length = result.length;
13380
13381 for (var key in value) {
13382 if ((inherited || hasOwnProperty.call(value, key)) &&
13383 !(skipIndexes && (
13384 // Safari 9 has enumerable `arguments.length` in strict mode.
13385 key == 'length' ||
13386 // Node.js 0.10 has enumerable non-index properties on buffers.
13387 (isBuff && (key == 'offset' || key == 'parent')) ||
13388 // PhantomJS 2 has enumerable non-index properties on typed arrays.
13389 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
13390 // Skip index properties.
13391 isIndex(key, length)
13392 ))) {
13393 result.push(key);
13394 }
13395 }
13396 return result;
13397}
13398
13399/**
13400 * Gets the index at which the `key` is found in `array` of key-value pairs.
13401 *
13402 * @private
13403 * @param {Array} array The array to inspect.
13404 * @param {*} key The key to search for.
13405 * @returns {number} Returns the index of the matched value, else `-1`.
13406 */
13407function assocIndexOf(array, key) {
13408 var length = array.length;
13409 while (length--) {
13410 if (eq(array[length][0], key)) {
13411 return length;
13412 }
13413 }
13414 return -1;
13415}
13416
13417/**
13418 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
13419 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
13420 * symbols of `object`.
13421 *
13422 * @private
13423 * @param {Object} object The object to query.
13424 * @param {Function} keysFunc The function to get the keys of `object`.
13425 * @param {Function} symbolsFunc The function to get the symbols of `object`.
13426 * @returns {Array} Returns the array of property names and symbols.
13427 */
13428function baseGetAllKeys(object, keysFunc, symbolsFunc) {
13429 var result = keysFunc(object);
13430 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
13431}
13432
13433/**
13434 * The base implementation of `getTag` without fallbacks for buggy environments.
13435 *
13436 * @private
13437 * @param {*} value The value to query.
13438 * @returns {string} Returns the `toStringTag`.
13439 */
13440function baseGetTag(value) {
13441 if (value == null) {
13442 return value === undefined ? undefinedTag : nullTag;
13443 }
13444 return (symToStringTag && symToStringTag in Object(value))
13445 ? getRawTag(value)
13446 : objectToString(value);
13447}
13448
13449/**
13450 * The base implementation of `_.isArguments`.
13451 *
13452 * @private
13453 * @param {*} value The value to check.
13454 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
13455 */
13456function baseIsArguments(value) {
13457 return isObjectLike(value) && baseGetTag(value) == argsTag;
13458}
13459
13460/**
13461 * The base implementation of `_.isEqual` which supports partial comparisons
13462 * and tracks traversed objects.
13463 *
13464 * @private
13465 * @param {*} value The value to compare.
13466 * @param {*} other The other value to compare.
13467 * @param {boolean} bitmask The bitmask flags.
13468 * 1 - Unordered comparison
13469 * 2 - Partial comparison
13470 * @param {Function} [customizer] The function to customize comparisons.
13471 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
13472 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
13473 */
13474function baseIsEqual(value, other, bitmask, customizer, stack) {
13475 if (value === other) {
13476 return true;
13477 }
13478 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
13479 return value !== value && other !== other;
13480 }
13481 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
13482}
13483
13484/**
13485 * A specialized version of `baseIsEqual` for arrays and objects which performs
13486 * deep comparisons and tracks traversed objects enabling objects with circular
13487 * references to be compared.
13488 *
13489 * @private
13490 * @param {Object} object The object to compare.
13491 * @param {Object} other The other object to compare.
13492 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13493 * @param {Function} customizer The function to customize comparisons.
13494 * @param {Function} equalFunc The function to determine equivalents of values.
13495 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
13496 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
13497 */
13498function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
13499 var objIsArr = isArray(object),
13500 othIsArr = isArray(other),
13501 objTag = objIsArr ? arrayTag : getTag(object),
13502 othTag = othIsArr ? arrayTag : getTag(other);
13503
13504 objTag = objTag == argsTag ? objectTag : objTag;
13505 othTag = othTag == argsTag ? objectTag : othTag;
13506
13507 var objIsObj = objTag == objectTag,
13508 othIsObj = othTag == objectTag,
13509 isSameTag = objTag == othTag;
13510
13511 if (isSameTag && isBuffer(object)) {
13512 if (!isBuffer(other)) {
13513 return false;
13514 }
13515 objIsArr = true;
13516 objIsObj = false;
13517 }
13518 if (isSameTag && !objIsObj) {
13519 stack || (stack = new Stack);
13520 return (objIsArr || isTypedArray(object))
13521 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
13522 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
13523 }
13524 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
13525 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
13526 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
13527
13528 if (objIsWrapped || othIsWrapped) {
13529 var objUnwrapped = objIsWrapped ? object.value() : object,
13530 othUnwrapped = othIsWrapped ? other.value() : other;
13531
13532 stack || (stack = new Stack);
13533 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
13534 }
13535 }
13536 if (!isSameTag) {
13537 return false;
13538 }
13539 stack || (stack = new Stack);
13540 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
13541}
13542
13543/**
13544 * The base implementation of `_.isNative` without bad shim checks.
13545 *
13546 * @private
13547 * @param {*} value The value to check.
13548 * @returns {boolean} Returns `true` if `value` is a native function,
13549 * else `false`.
13550 */
13551function baseIsNative(value) {
13552 if (!isObject(value) || isMasked(value)) {
13553 return false;
13554 }
13555 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
13556 return pattern.test(toSource(value));
13557}
13558
13559/**
13560 * The base implementation of `_.isTypedArray` without Node.js optimizations.
13561 *
13562 * @private
13563 * @param {*} value The value to check.
13564 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
13565 */
13566function baseIsTypedArray(value) {
13567 return isObjectLike(value) &&
13568 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
13569}
13570
13571/**
13572 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
13573 *
13574 * @private
13575 * @param {Object} object The object to query.
13576 * @returns {Array} Returns the array of property names.
13577 */
13578function baseKeys(object) {
13579 if (!isPrototype(object)) {
13580 return nativeKeys(object);
13581 }
13582 var result = [];
13583 for (var key in Object(object)) {
13584 if (hasOwnProperty.call(object, key) && key != 'constructor') {
13585 result.push(key);
13586 }
13587 }
13588 return result;
13589}
13590
13591/**
13592 * A specialized version of `baseIsEqualDeep` for arrays with support for
13593 * partial deep comparisons.
13594 *
13595 * @private
13596 * @param {Array} array The array to compare.
13597 * @param {Array} other The other array to compare.
13598 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13599 * @param {Function} customizer The function to customize comparisons.
13600 * @param {Function} equalFunc The function to determine equivalents of values.
13601 * @param {Object} stack Tracks traversed `array` and `other` objects.
13602 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
13603 */
13604function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
13605 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
13606 arrLength = array.length,
13607 othLength = other.length;
13608
13609 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
13610 return false;
13611 }
13612 // Assume cyclic values are equal.
13613 var stacked = stack.get(array);
13614 if (stacked && stack.get(other)) {
13615 return stacked == other;
13616 }
13617 var index = -1,
13618 result = true,
13619 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
13620
13621 stack.set(array, other);
13622 stack.set(other, array);
13623
13624 // Ignore non-index properties.
13625 while (++index < arrLength) {
13626 var arrValue = array[index],
13627 othValue = other[index];
13628
13629 if (customizer) {
13630 var compared = isPartial
13631 ? customizer(othValue, arrValue, index, other, array, stack)
13632 : customizer(arrValue, othValue, index, array, other, stack);
13633 }
13634 if (compared !== undefined) {
13635 if (compared) {
13636 continue;
13637 }
13638 result = false;
13639 break;
13640 }
13641 // Recursively compare arrays (susceptible to call stack limits).
13642 if (seen) {
13643 if (!arraySome(other, function(othValue, othIndex) {
13644 if (!cacheHas(seen, othIndex) &&
13645 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
13646 return seen.push(othIndex);
13647 }
13648 })) {
13649 result = false;
13650 break;
13651 }
13652 } else if (!(
13653 arrValue === othValue ||
13654 equalFunc(arrValue, othValue, bitmask, customizer, stack)
13655 )) {
13656 result = false;
13657 break;
13658 }
13659 }
13660 stack['delete'](array);
13661 stack['delete'](other);
13662 return result;
13663}
13664
13665/**
13666 * A specialized version of `baseIsEqualDeep` for comparing objects of
13667 * the same `toStringTag`.
13668 *
13669 * **Note:** This function only supports comparing values with tags of
13670 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
13671 *
13672 * @private
13673 * @param {Object} object The object to compare.
13674 * @param {Object} other The other object to compare.
13675 * @param {string} tag The `toStringTag` of the objects to compare.
13676 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13677 * @param {Function} customizer The function to customize comparisons.
13678 * @param {Function} equalFunc The function to determine equivalents of values.
13679 * @param {Object} stack Tracks traversed `object` and `other` objects.
13680 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
13681 */
13682function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
13683 switch (tag) {
13684 case dataViewTag:
13685 if ((object.byteLength != other.byteLength) ||
13686 (object.byteOffset != other.byteOffset)) {
13687 return false;
13688 }
13689 object = object.buffer;
13690 other = other.buffer;
13691
13692 case arrayBufferTag:
13693 if ((object.byteLength != other.byteLength) ||
13694 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
13695 return false;
13696 }
13697 return true;
13698
13699 case boolTag:
13700 case dateTag:
13701 case numberTag:
13702 // Coerce booleans to `1` or `0` and dates to milliseconds.
13703 // Invalid dates are coerced to `NaN`.
13704 return eq(+object, +other);
13705
13706 case errorTag:
13707 return object.name == other.name && object.message == other.message;
13708
13709 case regexpTag:
13710 case stringTag:
13711 // Coerce regexes to strings and treat strings, primitives and objects,
13712 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
13713 // for more details.
13714 return object == (other + '');
13715
13716 case mapTag:
13717 var convert = mapToArray;
13718
13719 case setTag:
13720 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
13721 convert || (convert = setToArray);
13722
13723 if (object.size != other.size && !isPartial) {
13724 return false;
13725 }
13726 // Assume cyclic values are equal.
13727 var stacked = stack.get(object);
13728 if (stacked) {
13729 return stacked == other;
13730 }
13731 bitmask |= COMPARE_UNORDERED_FLAG;
13732
13733 // Recursively compare objects (susceptible to call stack limits).
13734 stack.set(object, other);
13735 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
13736 stack['delete'](object);
13737 return result;
13738
13739 case symbolTag:
13740 if (symbolValueOf) {
13741 return symbolValueOf.call(object) == symbolValueOf.call(other);
13742 }
13743 }
13744 return false;
13745}
13746
13747/**
13748 * A specialized version of `baseIsEqualDeep` for objects with support for
13749 * partial deep comparisons.
13750 *
13751 * @private
13752 * @param {Object} object The object to compare.
13753 * @param {Object} other The other object to compare.
13754 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13755 * @param {Function} customizer The function to customize comparisons.
13756 * @param {Function} equalFunc The function to determine equivalents of values.
13757 * @param {Object} stack Tracks traversed `object` and `other` objects.
13758 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
13759 */
13760function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
13761 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
13762 objProps = getAllKeys(object),
13763 objLength = objProps.length,
13764 othProps = getAllKeys(other),
13765 othLength = othProps.length;
13766
13767 if (objLength != othLength && !isPartial) {
13768 return false;
13769 }
13770 var index = objLength;
13771 while (index--) {
13772 var key = objProps[index];
13773 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
13774 return false;
13775 }
13776 }
13777 // Assume cyclic values are equal.
13778 var stacked = stack.get(object);
13779 if (stacked && stack.get(other)) {
13780 return stacked == other;
13781 }
13782 var result = true;
13783 stack.set(object, other);
13784 stack.set(other, object);
13785
13786 var skipCtor = isPartial;
13787 while (++index < objLength) {
13788 key = objProps[index];
13789 var objValue = object[key],
13790 othValue = other[key];
13791
13792 if (customizer) {
13793 var compared = isPartial
13794 ? customizer(othValue, objValue, key, other, object, stack)
13795 : customizer(objValue, othValue, key, object, other, stack);
13796 }
13797 // Recursively compare objects (susceptible to call stack limits).
13798 if (!(compared === undefined
13799 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
13800 : compared
13801 )) {
13802 result = false;
13803 break;
13804 }
13805 skipCtor || (skipCtor = key == 'constructor');
13806 }
13807 if (result && !skipCtor) {
13808 var objCtor = object.constructor,
13809 othCtor = other.constructor;
13810
13811 // Non `Object` object instances with different constructors are not equal.
13812 if (objCtor != othCtor &&
13813 ('constructor' in object && 'constructor' in other) &&
13814 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
13815 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
13816 result = false;
13817 }
13818 }
13819 stack['delete'](object);
13820 stack['delete'](other);
13821 return result;
13822}
13823
13824/**
13825 * Creates an array of own enumerable property names and symbols of `object`.
13826 *
13827 * @private
13828 * @param {Object} object The object to query.
13829 * @returns {Array} Returns the array of property names and symbols.
13830 */
13831function getAllKeys(object) {
13832 return baseGetAllKeys(object, keys, getSymbols);
13833}
13834
13835/**
13836 * Gets the data for `map`.
13837 *
13838 * @private
13839 * @param {Object} map The map to query.
13840 * @param {string} key The reference key.
13841 * @returns {*} Returns the map data.
13842 */
13843function getMapData(map, key) {
13844 var data = map.__data__;
13845 return isKeyable(key)
13846 ? data[typeof key == 'string' ? 'string' : 'hash']
13847 : data.map;
13848}
13849
13850/**
13851 * Gets the native function at `key` of `object`.
13852 *
13853 * @private
13854 * @param {Object} object The object to query.
13855 * @param {string} key The key of the method to get.
13856 * @returns {*} Returns the function if it's native, else `undefined`.
13857 */
13858function getNative(object, key) {
13859 var value = getValue(object, key);
13860 return baseIsNative(value) ? value : undefined;
13861}
13862
13863/**
13864 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
13865 *
13866 * @private
13867 * @param {*} value The value to query.
13868 * @returns {string} Returns the raw `toStringTag`.
13869 */
13870function getRawTag(value) {
13871 var isOwn = hasOwnProperty.call(value, symToStringTag),
13872 tag = value[symToStringTag];
13873
13874 try {
13875 value[symToStringTag] = undefined;
13876 var unmasked = true;
13877 } catch (e) {}
13878
13879 var result = nativeObjectToString.call(value);
13880 if (unmasked) {
13881 if (isOwn) {
13882 value[symToStringTag] = tag;
13883 } else {
13884 delete value[symToStringTag];
13885 }
13886 }
13887 return result;
13888}
13889
13890/**
13891 * Creates an array of the own enumerable symbols of `object`.
13892 *
13893 * @private
13894 * @param {Object} object The object to query.
13895 * @returns {Array} Returns the array of symbols.
13896 */
13897var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
13898 if (object == null) {
13899 return [];
13900 }
13901 object = Object(object);
13902 return arrayFilter(nativeGetSymbols(object), function(symbol) {
13903 return propertyIsEnumerable.call(object, symbol);
13904 });
13905};
13906
13907/**
13908 * Gets the `toStringTag` of `value`.
13909 *
13910 * @private
13911 * @param {*} value The value to query.
13912 * @returns {string} Returns the `toStringTag`.
13913 */
13914var getTag = baseGetTag;
13915
13916// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
13917if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
13918 (Map && getTag(new Map) != mapTag) ||
13919 (Promise && getTag(Promise.resolve()) != promiseTag) ||
13920 (Set && getTag(new Set) != setTag) ||
13921 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
13922 getTag = function(value) {
13923 var result = baseGetTag(value),
13924 Ctor = result == objectTag ? value.constructor : undefined,
13925 ctorString = Ctor ? toSource(Ctor) : '';
13926
13927 if (ctorString) {
13928 switch (ctorString) {
13929 case dataViewCtorString: return dataViewTag;
13930 case mapCtorString: return mapTag;
13931 case promiseCtorString: return promiseTag;
13932 case setCtorString: return setTag;
13933 case weakMapCtorString: return weakMapTag;
13934 }
13935 }
13936 return result;
13937 };
13938}
13939
13940/**
13941 * Checks if `value` is a valid array-like index.
13942 *
13943 * @private
13944 * @param {*} value The value to check.
13945 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
13946 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
13947 */
13948function isIndex(value, length) {
13949 length = length == null ? MAX_SAFE_INTEGER : length;
13950 return !!length &&
13951 (typeof value == 'number' || reIsUint.test(value)) &&
13952 (value > -1 && value % 1 == 0 && value < length);
13953}
13954
13955/**
13956 * Checks if `value` is suitable for use as unique object key.
13957 *
13958 * @private
13959 * @param {*} value The value to check.
13960 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
13961 */
13962function isKeyable(value) {
13963 var type = typeof value;
13964 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
13965 ? (value !== '__proto__')
13966 : (value === null);
13967}
13968
13969/**
13970 * Checks if `func` has its source masked.
13971 *
13972 * @private
13973 * @param {Function} func The function to check.
13974 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
13975 */
13976function isMasked(func) {
13977 return !!maskSrcKey && (maskSrcKey in func);
13978}
13979
13980/**
13981 * Checks if `value` is likely a prototype object.
13982 *
13983 * @private
13984 * @param {*} value The value to check.
13985 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
13986 */
13987function isPrototype(value) {
13988 var Ctor = value && value.constructor,
13989 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
13990
13991 return value === proto;
13992}
13993
13994/**
13995 * Converts `value` to a string using `Object.prototype.toString`.
13996 *
13997 * @private
13998 * @param {*} value The value to convert.
13999 * @returns {string} Returns the converted string.
14000 */
14001function objectToString(value) {
14002 return nativeObjectToString.call(value);
14003}
14004
14005/**
14006 * Converts `func` to its source code.
14007 *
14008 * @private
14009 * @param {Function} func The function to convert.
14010 * @returns {string} Returns the source code.
14011 */
14012function toSource(func) {
14013 if (func != null) {
14014 try {
14015 return funcToString.call(func);
14016 } catch (e) {}
14017 try {
14018 return (func + '');
14019 } catch (e) {}
14020 }
14021 return '';
14022}
14023
14024/**
14025 * Performs a
14026 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
14027 * comparison between two values to determine if they are equivalent.
14028 *
14029 * @static
14030 * @memberOf _
14031 * @since 4.0.0
14032 * @category Lang
14033 * @param {*} value The value to compare.
14034 * @param {*} other The other value to compare.
14035 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
14036 * @example
14037 *
14038 * var object = { 'a': 1 };
14039 * var other = { 'a': 1 };
14040 *
14041 * _.eq(object, object);
14042 * // => true
14043 *
14044 * _.eq(object, other);
14045 * // => false
14046 *
14047 * _.eq('a', 'a');
14048 * // => true
14049 *
14050 * _.eq('a', Object('a'));
14051 * // => false
14052 *
14053 * _.eq(NaN, NaN);
14054 * // => true
14055 */
14056function eq(value, other) {
14057 return value === other || (value !== value && other !== other);
14058}
14059
14060/**
14061 * Checks if `value` is likely an `arguments` object.
14062 *
14063 * @static
14064 * @memberOf _
14065 * @since 0.1.0
14066 * @category Lang
14067 * @param {*} value The value to check.
14068 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
14069 * else `false`.
14070 * @example
14071 *
14072 * _.isArguments(function() { return arguments; }());
14073 * // => true
14074 *
14075 * _.isArguments([1, 2, 3]);
14076 * // => false
14077 */
14078var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
14079 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
14080 !propertyIsEnumerable.call(value, 'callee');
14081};
14082
14083/**
14084 * Checks if `value` is classified as an `Array` object.
14085 *
14086 * @static
14087 * @memberOf _
14088 * @since 0.1.0
14089 * @category Lang
14090 * @param {*} value The value to check.
14091 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
14092 * @example
14093 *
14094 * _.isArray([1, 2, 3]);
14095 * // => true
14096 *
14097 * _.isArray(document.body.children);
14098 * // => false
14099 *
14100 * _.isArray('abc');
14101 * // => false
14102 *
14103 * _.isArray(_.noop);
14104 * // => false
14105 */
14106var isArray = Array.isArray;
14107
14108/**
14109 * Checks if `value` is array-like. A value is considered array-like if it's
14110 * not a function and has a `value.length` that's an integer greater than or
14111 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
14112 *
14113 * @static
14114 * @memberOf _
14115 * @since 4.0.0
14116 * @category Lang
14117 * @param {*} value The value to check.
14118 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
14119 * @example
14120 *
14121 * _.isArrayLike([1, 2, 3]);
14122 * // => true
14123 *
14124 * _.isArrayLike(document.body.children);
14125 * // => true
14126 *
14127 * _.isArrayLike('abc');
14128 * // => true
14129 *
14130 * _.isArrayLike(_.noop);
14131 * // => false
14132 */
14133function isArrayLike(value) {
14134 return value != null && isLength(value.length) && !isFunction(value);
14135}
14136
14137/**
14138 * Checks if `value` is a buffer.
14139 *
14140 * @static
14141 * @memberOf _
14142 * @since 4.3.0
14143 * @category Lang
14144 * @param {*} value The value to check.
14145 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
14146 * @example
14147 *
14148 * _.isBuffer(new Buffer(2));
14149 * // => true
14150 *
14151 * _.isBuffer(new Uint8Array(2));
14152 * // => false
14153 */
14154var isBuffer = nativeIsBuffer || stubFalse;
14155
14156/**
14157 * Performs a deep comparison between two values to determine if they are
14158 * equivalent.
14159 *
14160 * **Note:** This method supports comparing arrays, array buffers, booleans,
14161 * date objects, error objects, maps, numbers, `Object` objects, regexes,
14162 * sets, strings, symbols, and typed arrays. `Object` objects are compared
14163 * by their own, not inherited, enumerable properties. Functions and DOM
14164 * nodes are compared by strict equality, i.e. `===`.
14165 *
14166 * @static
14167 * @memberOf _
14168 * @since 0.1.0
14169 * @category Lang
14170 * @param {*} value The value to compare.
14171 * @param {*} other The other value to compare.
14172 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
14173 * @example
14174 *
14175 * var object = { 'a': 1 };
14176 * var other = { 'a': 1 };
14177 *
14178 * _.isEqual(object, other);
14179 * // => true
14180 *
14181 * object === other;
14182 * // => false
14183 */
14184function isEqual(value, other) {
14185 return baseIsEqual(value, other);
14186}
14187
14188/**
14189 * Checks if `value` is classified as a `Function` object.
14190 *
14191 * @static
14192 * @memberOf _
14193 * @since 0.1.0
14194 * @category Lang
14195 * @param {*} value The value to check.
14196 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
14197 * @example
14198 *
14199 * _.isFunction(_);
14200 * // => true
14201 *
14202 * _.isFunction(/abc/);
14203 * // => false
14204 */
14205function isFunction(value) {
14206 if (!isObject(value)) {
14207 return false;
14208 }
14209 // The use of `Object#toString` avoids issues with the `typeof` operator
14210 // in Safari 9 which returns 'object' for typed arrays and other constructors.
14211 var tag = baseGetTag(value);
14212 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
14213}
14214
14215/**
14216 * Checks if `value` is a valid array-like length.
14217 *
14218 * **Note:** This method is loosely based on
14219 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
14220 *
14221 * @static
14222 * @memberOf _
14223 * @since 4.0.0
14224 * @category Lang
14225 * @param {*} value The value to check.
14226 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
14227 * @example
14228 *
14229 * _.isLength(3);
14230 * // => true
14231 *
14232 * _.isLength(Number.MIN_VALUE);
14233 * // => false
14234 *
14235 * _.isLength(Infinity);
14236 * // => false
14237 *
14238 * _.isLength('3');
14239 * // => false
14240 */
14241function isLength(value) {
14242 return typeof value == 'number' &&
14243 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
14244}
14245
14246/**
14247 * Checks if `value` is the
14248 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
14249 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
14250 *
14251 * @static
14252 * @memberOf _
14253 * @since 0.1.0
14254 * @category Lang
14255 * @param {*} value The value to check.
14256 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
14257 * @example
14258 *
14259 * _.isObject({});
14260 * // => true
14261 *
14262 * _.isObject([1, 2, 3]);
14263 * // => true
14264 *
14265 * _.isObject(_.noop);
14266 * // => true
14267 *
14268 * _.isObject(null);
14269 * // => false
14270 */
14271function isObject(value) {
14272 var type = typeof value;
14273 return value != null && (type == 'object' || type == 'function');
14274}
14275
14276/**
14277 * Checks if `value` is object-like. A value is object-like if it's not `null`
14278 * and has a `typeof` result of "object".
14279 *
14280 * @static
14281 * @memberOf _
14282 * @since 4.0.0
14283 * @category Lang
14284 * @param {*} value The value to check.
14285 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
14286 * @example
14287 *
14288 * _.isObjectLike({});
14289 * // => true
14290 *
14291 * _.isObjectLike([1, 2, 3]);
14292 * // => true
14293 *
14294 * _.isObjectLike(_.noop);
14295 * // => false
14296 *
14297 * _.isObjectLike(null);
14298 * // => false
14299 */
14300function isObjectLike(value) {
14301 return value != null && typeof value == 'object';
14302}
14303
14304/**
14305 * Checks if `value` is classified as a typed array.
14306 *
14307 * @static
14308 * @memberOf _
14309 * @since 3.0.0
14310 * @category Lang
14311 * @param {*} value The value to check.
14312 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
14313 * @example
14314 *
14315 * _.isTypedArray(new Uint8Array);
14316 * // => true
14317 *
14318 * _.isTypedArray([]);
14319 * // => false
14320 */
14321var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
14322
14323/**
14324 * Creates an array of the own enumerable property names of `object`.
14325 *
14326 * **Note:** Non-object values are coerced to objects. See the
14327 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
14328 * for more details.
14329 *
14330 * @static
14331 * @since 0.1.0
14332 * @memberOf _
14333 * @category Object
14334 * @param {Object} object The object to query.
14335 * @returns {Array} Returns the array of property names.
14336 * @example
14337 *
14338 * function Foo() {
14339 * this.a = 1;
14340 * this.b = 2;
14341 * }
14342 *
14343 * Foo.prototype.c = 3;
14344 *
14345 * _.keys(new Foo);
14346 * // => ['a', 'b'] (iteration order is not guaranteed)
14347 *
14348 * _.keys('hi');
14349 * // => ['0', '1']
14350 */
14351function keys(object) {
14352 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
14353}
14354
14355/**
14356 * This method returns a new empty array.
14357 *
14358 * @static
14359 * @memberOf _
14360 * @since 4.13.0
14361 * @category Util
14362 * @returns {Array} Returns the new empty array.
14363 * @example
14364 *
14365 * var arrays = _.times(2, _.stubArray);
14366 *
14367 * console.log(arrays);
14368 * // => [[], []]
14369 *
14370 * console.log(arrays[0] === arrays[1]);
14371 * // => false
14372 */
14373function stubArray() {
14374 return [];
14375}
14376
14377/**
14378 * This method returns `false`.
14379 *
14380 * @static
14381 * @memberOf _
14382 * @since 4.13.0
14383 * @category Util
14384 * @returns {boolean} Returns `false`.
14385 * @example
14386 *
14387 * _.times(2, _.stubFalse);
14388 * // => [false, false]
14389 */
14390function stubFalse() {
14391 return false;
14392}
14393
14394module.exports = isEqual;
14395
14396}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
14397
14398},{}],122:[function(require,module,exports){
14399"use strict";
14400
14401var format = require("format-util");
14402var slice = Array.prototype.slice;
14403var protectedProperties = ["name", "message", "stack"];
14404var errorPrototypeProperties = [
14405 "name", "message", "description", "number", "code", "fileName", "lineNumber", "columnNumber",
14406 "sourceURL", "line", "column", "stack"
14407];
14408
14409module.exports = create(Error);
14410module.exports.error = create(Error);
14411module.exports.eval = create(EvalError);
14412module.exports.range = create(RangeError);
14413module.exports.reference = create(ReferenceError);
14414module.exports.syntax = create(SyntaxError);
14415module.exports.type = create(TypeError);
14416module.exports.uri = create(URIError);
14417module.exports.formatter = format;
14418
14419/**
14420 * Creates a new {@link ono} function that creates the given Error class.
14421 *
14422 * @param {Class} Klass - The Error subclass to create
14423 * @returns {ono}
14424 */
14425function create (Klass) {
14426 /**
14427 * @param {Error} [err] - The original error, if any
14428 * @param {object} [props] - An object whose properties will be added to the error object
14429 * @param {string} [message] - The error message. May contain {@link util#format} placeholders
14430 * @param {...*} [params] - Parameters that map to the `message` placeholders
14431 * @returns {Error}
14432 */
14433 return function onoFactory (err, props, message, params) { // eslint-disable-line no-unused-vars
14434 var formatArgs = [];
14435 var formattedMessage = "";
14436
14437 // Determine which arguments were actually specified
14438 if (typeof err === "string") {
14439 formatArgs = slice.call(arguments);
14440 err = props = undefined;
14441 }
14442 else if (typeof props === "string") {
14443 formatArgs = slice.call(arguments, 1);
14444 props = undefined;
14445 }
14446 else if (typeof message === "string") {
14447 formatArgs = slice.call(arguments, 2);
14448 }
14449
14450 // If there are any format arguments, then format the error message
14451 if (formatArgs.length > 0) {
14452 formattedMessage = module.exports.formatter.apply(null, formatArgs);
14453 }
14454
14455 if (err && err.message) {
14456 // The inner-error's message will be added to the new message
14457 formattedMessage += (formattedMessage ? " \n" : "") + err.message;
14458 }
14459
14460 // Create the new error
14461 // NOTE: DON'T move this to a separate function! We don't want to pollute the stack trace
14462 var newError = new Klass(formattedMessage);
14463
14464 // Extend the new error with the additional properties
14465 extendError(newError, err); // Copy properties of the original error
14466 extendToJSON(newError); // Replace the original toJSON method
14467 extend(newError, props); // Copy custom properties, possibly including a custom toJSON method
14468
14469 return newError;
14470 };
14471}
14472
14473/**
14474 * Extends the targetError with the properties of the source error.
14475 *
14476 * @param {Error} targetError - The error object to extend
14477 * @param {?Error} sourceError - The source error object, if any
14478 */
14479function extendError (targetError, sourceError) {
14480 extendStack(targetError, sourceError);
14481 extend(targetError, sourceError);
14482}
14483
14484/**
14485 * JavaScript engines differ in how errors are serialized to JSON - especially when it comes
14486 * to custom error properties and stack traces. So we add our own toJSON method that ALWAYS
14487 * outputs every property of the error.
14488 */
14489function extendToJSON (error) {
14490 error.toJSON = errorToJSON;
14491
14492 // Also add an inspect() method, for compatibility with Node.js' `util.inspect()` method
14493 error.inspect = errorToString;
14494}
14495
14496/**
14497 * Extends the target object with the properties of the source object.
14498 *
14499 * @param {object} target - The object to extend
14500 * @param {?source} source - The object whose properties are copied
14501 */
14502function extend (target, source) {
14503 if (source && typeof source === "object") {
14504 var keys = Object.keys(source);
14505 for (var i = 0; i < keys.length; i++) {
14506 var key = keys[i];
14507
14508 // Don't copy "protected" properties, since they have special meaning/behavior
14509 // and are set by the onoFactory function
14510 if (protectedProperties.indexOf(key) >= 0) {
14511 continue;
14512 }
14513
14514 try {
14515 target[key] = source[key];
14516 }
14517 catch (e) {
14518 // This property is read-only, so it can't be copied
14519 }
14520 }
14521 }
14522}
14523
14524/**
14525 * Custom JSON serializer for Error objects.
14526 * Returns all built-in error properties, as well as extended properties.
14527 *
14528 * @returns {object}
14529 */
14530function errorToJSON () {
14531 var json = {};
14532
14533 // Get all the properties of this error
14534 var keys = Object.keys(this);
14535
14536 // Also include properties from the Error prototype
14537 keys = keys.concat(errorPrototypeProperties);
14538
14539 for (var i = 0; i < keys.length; i++) {
14540 var key = keys[i];
14541 var value = this[key];
14542 var type = typeof value;
14543 if (type !== "undefined" && type !== "function") {
14544 json[key] = value;
14545 }
14546 }
14547
14548 return json;
14549}
14550
14551/**
14552 * Serializes Error objects as human-readable JSON strings for debugging/logging purposes.
14553 *
14554 * @returns {string}
14555 */
14556function errorToString () {
14557 return JSON.stringify(this, null, 2).replace(/\\n/g, "\n");
14558}
14559
14560/**
14561 * Extend the error stack to include its cause
14562 *
14563 * @param {Error} targetError
14564 * @param {Error} sourceError
14565 */
14566function extendStack (targetError, sourceError) {
14567 if (hasLazyStack(targetError)) {
14568 if (sourceError) {
14569 lazyJoinStacks(targetError, sourceError);
14570 }
14571 else {
14572 lazyPopStack(targetError);
14573 }
14574 }
14575 else {
14576 if (sourceError) {
14577 targetError.stack = joinStacks(targetError.stack, sourceError.stack);
14578 }
14579 else {
14580 targetError.stack = popStack(targetError.stack);
14581 }
14582 }
14583}
14584
14585/**
14586 * Appends the original {@link Error#stack} property to the new Error's stack.
14587 *
14588 * @param {string} newStack
14589 * @param {string} originalStack
14590 * @returns {string}
14591 */
14592function joinStacks (newStack, originalStack) {
14593 newStack = popStack(newStack);
14594
14595 if (newStack && originalStack) {
14596 return newStack + "\n\n" + originalStack;
14597 }
14598 else {
14599 return newStack || originalStack;
14600 }
14601}
14602
14603/**
14604 * Removes Ono from the stack, so that the stack starts at the original error location
14605 *
14606 * @param {string} stack
14607 * @returns {string}
14608 */
14609function popStack (stack) {
14610 if (stack) {
14611 var lines = stack.split("\n");
14612
14613 if (lines.length < 2) {
14614 // The stack only has one line, so there's nothing we can remove
14615 return stack;
14616 }
14617
14618 // Find the `onoFactory` call in the stack, and remove it
14619 for (var i = 0; i < lines.length; i++) {
14620 var line = lines[i];
14621 if (line.indexOf("onoFactory") >= 0) {
14622 lines.splice(i, 1);
14623 return lines.join("\n");
14624 }
14625 }
14626
14627 // If we get here, then the stack doesn't contain a call to `onoFactory`.
14628 // This may be due to minification or some optimization of the JS engine.
14629 // So just return the stack as-is.
14630 return stack;
14631 }
14632}
14633
14634/**
14635 * Does a one-time determination of whether this JavaScript engine
14636 * supports lazy `Error.stack` properties.
14637 */
14638var supportsLazyStack = (function () {
14639 return !!(
14640 // ES5 property descriptors must be supported
14641 Object.getOwnPropertyDescriptor && Object.defineProperty &&
14642
14643 // Chrome on Android doesn't support lazy stacks :(
14644 (typeof navigator === "undefined" || !/Android/.test(navigator.userAgent))
14645 );
14646}());
14647
14648/**
14649 * Does this error have a lazy stack property?
14650 *
14651 * @param {Error} err
14652 * @returns {boolean}
14653 */
14654function hasLazyStack (err) {
14655 if (!supportsLazyStack) {
14656 return false;
14657 }
14658
14659 var descriptor = Object.getOwnPropertyDescriptor(err, "stack");
14660 if (!descriptor) {
14661 return false;
14662 }
14663 return typeof descriptor.get === "function";
14664}
14665
14666/**
14667 * Calls {@link joinStacks} lazily, when the {@link Error#stack} property is accessed.
14668 *
14669 * @param {Error} targetError
14670 * @param {Error} sourceError
14671 */
14672function lazyJoinStacks (targetError, sourceError) {
14673 var targetStack = Object.getOwnPropertyDescriptor(targetError, "stack");
14674
14675 Object.defineProperty(targetError, "stack", {
14676 get: function () {
14677 return joinStacks(targetStack.get.apply(targetError), sourceError.stack);
14678 },
14679 enumerable: false,
14680 configurable: true
14681 });
14682}
14683
14684/**
14685 * Calls {@link popStack} lazily, when the {@link Error#stack} property is accessed.
14686 *
14687 * @param {Error} error
14688 */
14689function lazyPopStack (error) {
14690 var targetStack = Object.getOwnPropertyDescriptor(error, "stack");
14691
14692 Object.defineProperty(error, "stack", {
14693 get: function () {
14694 return popStack(targetStack.get.apply(error));
14695 },
14696 enumerable: false,
14697 configurable: true
14698 });
14699}
14700
14701},{"format-util":65}],123:[function(require,module,exports){
14702module.exports={
14703 "title": "A JSON Schema for OpenAPI 3.0.",
14704 "id": "http://openapis.org/v3/schema.json#",
14705 "$schema": "http://json-schema.org/draft-04/schema#",
14706 "type": "object",
14707 "description": "This is the root document object of the OpenAPI document.",
14708 "required": [
14709 "openapi",
14710 "info",
14711 "paths"
14712 ],
14713 "additionalProperties": false,
14714 "patternProperties": {
14715 "^x-": {
14716 "$ref": "#/definitions/specificationExtension"
14717 }
14718 },
14719 "properties": {
14720 "openapi": {
14721 "type": "string"
14722 },
14723 "info": {
14724 "$ref": "#/definitions/info"
14725 },
14726 "servers": {
14727 "type": "array",
14728 "items": {
14729 "$ref": "#/definitions/server"
14730 },
14731 "uniqueItems": true
14732 },
14733 "paths": {
14734 "$ref": "#/definitions/paths"
14735 },
14736 "components": {
14737 "$ref": "#/definitions/components"
14738 },
14739 "security": {
14740 "type": "array",
14741 "items": {
14742 "$ref": "#/definitions/securityRequirement"
14743 },
14744 "uniqueItems": true
14745 },
14746 "tags": {
14747 "type": "array",
14748 "items": {
14749 "$ref": "#/definitions/tag"
14750 },
14751 "uniqueItems": true
14752 },
14753 "externalDocs": {
14754 "$ref": "#/definitions/externalDocs"
14755 }
14756 },
14757 "definitions": {
14758 "info": {
14759 "type": "object",
14760 "description": "The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.",
14761 "required": [
14762 "title",
14763 "version"
14764 ],
14765 "additionalProperties": false,
14766 "patternProperties": {
14767 "^x-": {
14768 "$ref": "#/definitions/specificationExtension"
14769 }
14770 },
14771 "properties": {
14772 "title": {
14773 "type": "string"
14774 },
14775 "description": {
14776 "type": "string"
14777 },
14778 "termsOfService": {
14779 "type": "string"
14780 },
14781 "contact": {
14782 "$ref": "#/definitions/contact"
14783 },
14784 "license": {
14785 "$ref": "#/definitions/license"
14786 },
14787 "version": {
14788 "type": "string"
14789 }
14790 }
14791 },
14792 "contact": {
14793 "type": "object",
14794 "description": "Contact information for the exposed API.",
14795 "additionalProperties": false,
14796 "patternProperties": {
14797 "^x-": {
14798 "$ref": "#/definitions/specificationExtension"
14799 }
14800 },
14801 "properties": {
14802 "name": {
14803 "type": "string"
14804 },
14805 "url": {
14806 "type": "string"
14807 },
14808 "email": {
14809 "type": "string"
14810 }
14811 }
14812 },
14813 "license": {
14814 "type": "object",
14815 "description": "License information for the exposed API.",
14816 "required": [
14817 "name"
14818 ],
14819 "additionalProperties": false,
14820 "patternProperties": {
14821 "^x-": {
14822 "$ref": "#/definitions/specificationExtension"
14823 }
14824 },
14825 "properties": {
14826 "name": {
14827 "type": "string"
14828 },
14829 "url": {
14830 "type": "string"
14831 }
14832 }
14833 },
14834 "server": {
14835 "type": "object",
14836 "description": "An object representing a Server.",
14837 "required": [
14838 "url"
14839 ],
14840 "additionalProperties": false,
14841 "patternProperties": {
14842 "^x-": {
14843 "$ref": "#/definitions/specificationExtension"
14844 }
14845 },
14846 "properties": {
14847 "url": {
14848 "type": "string"
14849 },
14850 "description": {
14851 "type": "string"
14852 },
14853 "variables": {
14854 "$ref": "#/definitions/serverVariables"
14855 }
14856 }
14857 },
14858 "serverVariable": {
14859 "type": "object",
14860 "description": "An object representing a Server Variable for server URL template substitution.",
14861 "required": [
14862 "default"
14863 ],
14864 "additionalProperties": false,
14865 "patternProperties": {
14866 "^x-": {
14867 "$ref": "#/definitions/specificationExtension"
14868 }
14869 },
14870 "properties": {
14871 "enum": {
14872 "type": "array",
14873 "items": {
14874 "type": "string"
14875 },
14876 "uniqueItems": true
14877 },
14878 "default": {
14879 "type": "string"
14880 },
14881 "description": {
14882 "type": "string"
14883 }
14884 }
14885 },
14886 "components": {
14887 "type": "object",
14888 "description": "Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.",
14889 "additionalProperties": false,
14890 "patternProperties": {
14891 "^x-": {
14892 "$ref": "#/definitions/specificationExtension"
14893 }
14894 },
14895 "properties": {
14896 "schemas": {
14897 "$ref": "#/definitions/schemasOrReferences"
14898 },
14899 "responses": {
14900 "$ref": "#/definitions/responsesOrReferences"
14901 },
14902 "parameters": {
14903 "$ref": "#/definitions/parametersOrReferences"
14904 },
14905 "examples": {
14906 "$ref": "#/definitions/examplesOrReferences"
14907 },
14908 "requestBodies": {
14909 "$ref": "#/definitions/requestBodiesOrReferences"
14910 },
14911 "headers": {
14912 "$ref": "#/definitions/headersOrReferences"
14913 },
14914 "securitySchemes": {
14915 "$ref": "#/definitions/securitySchemesOrReferences"
14916 },
14917 "links": {
14918 "$ref": "#/definitions/linksOrReferences"
14919 },
14920 "callbacks": {
14921 "$ref": "#/definitions/callbacksOrReferences"
14922 }
14923 }
14924 },
14925 "paths": {
14926 "type": "object",
14927 "description": "Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the `Server Object` in order to construct the full URL. The Paths MAY be empty, due to ACL constraints.",
14928 "additionalProperties": false,
14929 "patternProperties": {
14930 "^/": {
14931 "$ref": "#/definitions/pathItem"
14932 },
14933 "^x-": {
14934 "$ref": "#/definitions/specificationExtension"
14935 }
14936 }
14937 },
14938 "pathItem": {
14939 "type": "object",
14940 "description": "Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.",
14941 "additionalProperties": false,
14942 "patternProperties": {
14943 "^x-": {
14944 "$ref": "#/definitions/specificationExtension"
14945 }
14946 },
14947 "properties": {
14948 "$ref": {
14949 "type": "string"
14950 },
14951 "summary": {
14952 "type": "string"
14953 },
14954 "description": {
14955 "type": "string"
14956 },
14957 "get": {
14958 "$ref": "#/definitions/operation"
14959 },
14960 "put": {
14961 "$ref": "#/definitions/operation"
14962 },
14963 "post": {
14964 "$ref": "#/definitions/operation"
14965 },
14966 "delete": {
14967 "$ref": "#/definitions/operation"
14968 },
14969 "options": {
14970 "$ref": "#/definitions/operation"
14971 },
14972 "head": {
14973 "$ref": "#/definitions/operation"
14974 },
14975 "patch": {
14976 "$ref": "#/definitions/operation"
14977 },
14978 "trace": {
14979 "$ref": "#/definitions/operation"
14980 },
14981 "servers": {
14982 "type": "array",
14983 "items": {
14984 "$ref": "#/definitions/server"
14985 },
14986 "uniqueItems": true
14987 },
14988 "parameters": {
14989 "type": "array",
14990 "items": {
14991 "$ref": "#/definitions/parameterOrReference"
14992 },
14993 "uniqueItems": true
14994 }
14995 }
14996 },
14997 "operation": {
14998 "type": "object",
14999 "description": "Describes a single API operation on a path.",
15000 "required": [
15001 "responses"
15002 ],
15003 "additionalProperties": false,
15004 "patternProperties": {
15005 "^x-": {
15006 "$ref": "#/definitions/specificationExtension"
15007 }
15008 },
15009 "properties": {
15010 "tags": {
15011 "type": "array",
15012 "items": {
15013 "type": "string"
15014 },
15015 "uniqueItems": true
15016 },
15017 "summary": {
15018 "type": "string"
15019 },
15020 "description": {
15021 "type": "string"
15022 },
15023 "externalDocs": {
15024 "$ref": "#/definitions/externalDocs"
15025 },
15026 "operationId": {
15027 "type": "string"
15028 },
15029 "parameters": {
15030 "type": "array",
15031 "items": {
15032 "$ref": "#/definitions/parameterOrReference"
15033 },
15034 "uniqueItems": true
15035 },
15036 "requestBody": {
15037 "$ref": "#/definitions/requestBodyOrReference"
15038 },
15039 "responses": {
15040 "$ref": "#/definitions/responses"
15041 },
15042 "callbacks": {
15043 "$ref": "#/definitions/callbacksOrReferences"
15044 },
15045 "deprecated": {
15046 "type": "boolean"
15047 },
15048 "security": {
15049 "type": "array",
15050 "items": {
15051 "$ref": "#/definitions/securityRequirement"
15052 },
15053 "uniqueItems": true
15054 },
15055 "servers": {
15056 "type": "array",
15057 "items": {
15058 "$ref": "#/definitions/server"
15059 },
15060 "uniqueItems": true
15061 }
15062 }
15063 },
15064 "externalDocs": {
15065 "type": "object",
15066 "description": "Allows referencing an external resource for extended documentation.",
15067 "required": [
15068 "url"
15069 ],
15070 "additionalProperties": false,
15071 "patternProperties": {
15072 "^x-": {
15073 "$ref": "#/definitions/specificationExtension"
15074 }
15075 },
15076 "properties": {
15077 "description": {
15078 "type": "string"
15079 },
15080 "url": {
15081 "type": "string"
15082 }
15083 }
15084 },
15085 "parameter": {
15086 "type": "object",
15087 "description": "Describes a single operation parameter. A unique parameter is defined by a combination of a name and location.",
15088 "required": [
15089 "name",
15090 "in"
15091 ],
15092 "additionalProperties": false,
15093 "patternProperties": {
15094 "^x-": {
15095 "$ref": "#/definitions/specificationExtension"
15096 }
15097 },
15098 "properties": {
15099 "name": {
15100 "type": "string"
15101 },
15102 "in": {
15103 "type": "string"
15104 },
15105 "description": {
15106 "type": "string"
15107 },
15108 "required": {
15109 "type": "boolean"
15110 },
15111 "deprecated": {
15112 "type": "boolean"
15113 },
15114 "allowEmptyValue": {
15115 "type": "boolean"
15116 },
15117 "style": {
15118 "type": "string"
15119 },
15120 "explode": {
15121 "type": "boolean"
15122 },
15123 "allowReserved": {
15124 "type": "boolean"
15125 },
15126 "schema": {
15127 "$ref": "#/definitions/schemaOrReference"
15128 },
15129 "example": {
15130 "$ref": "#/definitions/any"
15131 },
15132 "examples": {
15133 "$ref": "#/definitions/examplesOrReferences"
15134 },
15135 "content": {
15136 "$ref": "#/definitions/mediaTypes"
15137 }
15138 }
15139 },
15140 "requestBody": {
15141 "type": "object",
15142 "description": "Describes a single request body.",
15143 "required": [
15144 "content"
15145 ],
15146 "additionalProperties": false,
15147 "patternProperties": {
15148 "^x-": {
15149 "$ref": "#/definitions/specificationExtension"
15150 }
15151 },
15152 "properties": {
15153 "description": {
15154 "type": "string"
15155 },
15156 "content": {
15157 "$ref": "#/definitions/mediaTypes"
15158 },
15159 "required": {
15160 "type": "boolean"
15161 }
15162 }
15163 },
15164 "mediaType": {
15165 "type": "object",
15166 "description": "Each Media Type Object provides schema and examples for the media type identified by its key.",
15167 "additionalProperties": false,
15168 "patternProperties": {
15169 "^x-": {
15170 "$ref": "#/definitions/specificationExtension"
15171 }
15172 },
15173 "properties": {
15174 "schema": {
15175 "$ref": "#/definitions/schemaOrReference"
15176 },
15177 "example": {
15178 "$ref": "#/definitions/any"
15179 },
15180 "examples": {
15181 "$ref": "#/definitions/examplesOrReferences"
15182 },
15183 "encoding": {
15184 "$ref": "#/definitions/encodings"
15185 }
15186 }
15187 },
15188 "encoding": {
15189 "type": "object",
15190 "description": "A single encoding definition applied to a single schema property.",
15191 "additionalProperties": false,
15192 "patternProperties": {
15193 "^x-": {
15194 "$ref": "#/definitions/specificationExtension"
15195 }
15196 },
15197 "properties": {
15198 "contentType": {
15199 "type": "string"
15200 },
15201 "headers": {
15202 "$ref": "#/definitions/headersOrReferences"
15203 },
15204 "style": {
15205 "type": "string"
15206 },
15207 "explode": {
15208 "type": "boolean"
15209 },
15210 "allowReserved": {
15211 "type": "boolean"
15212 }
15213 }
15214 },
15215 "responses": {
15216 "type": "object",
15217 "description": "A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors. The `default` MAY be used as a default response object for all HTTP codes that are not covered individually by the specification. The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call.",
15218 "additionalProperties": false,
15219 "patternProperties": {
15220 "^([0-9X]{3})$": {
15221 "$ref": "#/definitions/responseOrReference"
15222 },
15223 "^x-": {
15224 "$ref": "#/definitions/specificationExtension"
15225 }
15226 },
15227 "properties": {
15228 "default": {
15229 "$ref": "#/definitions/responseOrReference"
15230 }
15231 }
15232 },
15233 "response": {
15234 "type": "object",
15235 "description": "Describes a single response from an API Operation, including design-time, static `links` to operations based on the response.",
15236 "required": [
15237 "description"
15238 ],
15239 "additionalProperties": false,
15240 "patternProperties": {
15241 "^x-": {
15242 "$ref": "#/definitions/specificationExtension"
15243 }
15244 },
15245 "properties": {
15246 "description": {
15247 "type": "string"
15248 },
15249 "headers": {
15250 "$ref": "#/definitions/headersOrReferences"
15251 },
15252 "content": {
15253 "$ref": "#/definitions/mediaTypes"
15254 },
15255 "links": {
15256 "$ref": "#/definitions/linksOrReferences"
15257 }
15258 }
15259 },
15260 "callback": {
15261 "type": "object",
15262 "description": "A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.",
15263 "additionalProperties": false,
15264 "patternProperties": {
15265 "^": {
15266 "$ref": "#/definitions/pathItem"
15267 },
15268 "^x-": {
15269 "$ref": "#/definitions/specificationExtension"
15270 }
15271 }
15272 },
15273 "example": {
15274 "type": "object",
15275 "description": "",
15276 "additionalProperties": false,
15277 "patternProperties": {
15278 "^x-": {
15279 "$ref": "#/definitions/specificationExtension"
15280 }
15281 },
15282 "properties": {
15283 "summary": {
15284 "type": "string"
15285 },
15286 "description": {
15287 "type": "string"
15288 },
15289 "value": {
15290 "$ref": "#/definitions/any"
15291 },
15292 "externalValue": {
15293 "type": "string"
15294 }
15295 }
15296 },
15297 "link": {
15298 "type": "object",
15299 "description": "The `Link object` represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. For computing links, and providing instructions to execute them, a runtime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation.",
15300 "additionalProperties": false,
15301 "patternProperties": {
15302 "^x-": {
15303 "$ref": "#/definitions/specificationExtension"
15304 }
15305 },
15306 "properties": {
15307 "operationRef": {
15308 "type": "string"
15309 },
15310 "operationId": {
15311 "type": "string"
15312 },
15313 "parameters": {
15314 "$ref": "#/definitions/anysOrExpressions"
15315 },
15316 "requestBody": {
15317 "$ref": "#/definitions/anyOrExpression"
15318 },
15319 "description": {
15320 "type": "string"
15321 },
15322 "server": {
15323 "$ref": "#/definitions/server"
15324 }
15325 }
15326 },
15327 "header": {
15328 "type": "object",
15329 "description": "The Header Object follows the structure of the Parameter Object with the following changes: 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. 1. `in` MUST NOT be specified, it is implicitly in `header`. 1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, `style`).",
15330 "additionalProperties": false,
15331 "patternProperties": {
15332 "^x-": {
15333 "$ref": "#/definitions/specificationExtension"
15334 }
15335 },
15336 "properties": {
15337 "description": {
15338 "type": "string"
15339 },
15340 "required": {
15341 "type": "boolean"
15342 },
15343 "deprecated": {
15344 "type": "boolean"
15345 },
15346 "allowEmptyValue": {
15347 "type": "boolean"
15348 },
15349 "style": {
15350 "type": "string"
15351 },
15352 "explode": {
15353 "type": "boolean"
15354 },
15355 "allowReserved": {
15356 "type": "boolean"
15357 },
15358 "schema": {
15359 "$ref": "#/definitions/schemaOrReference"
15360 },
15361 "example": {
15362 "$ref": "#/definitions/any"
15363 },
15364 "examples": {
15365 "$ref": "#/definitions/examplesOrReferences"
15366 },
15367 "content": {
15368 "$ref": "#/definitions/mediaTypes"
15369 }
15370 }
15371 },
15372 "tag": {
15373 "type": "object",
15374 "description": "Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.",
15375 "required": [
15376 "name"
15377 ],
15378 "additionalProperties": false,
15379 "patternProperties": {
15380 "^x-": {
15381 "$ref": "#/definitions/specificationExtension"
15382 }
15383 },
15384 "properties": {
15385 "name": {
15386 "type": "string"
15387 },
15388 "description": {
15389 "type": "string"
15390 },
15391 "externalDocs": {
15392 "$ref": "#/definitions/externalDocs"
15393 }
15394 }
15395 },
15396 "examples": {
15397 "type": "object",
15398 "description": "",
15399 "additionalProperties": false
15400 },
15401 "reference": {
15402 "type": "object",
15403 "description": "A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification.",
15404 "required": [
15405 "$ref"
15406 ],
15407 "additionalProperties": false,
15408 "properties": {
15409 "$ref": {
15410 "type": "string"
15411 }
15412 }
15413 },
15414 "schema": {
15415 "type": "object",
15416 "description": "The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema.",
15417 "additionalProperties": false,
15418 "patternProperties": {
15419 "^x-": {
15420 "$ref": "#/definitions/specificationExtension"
15421 }
15422 },
15423 "properties": {
15424 "nullable": {
15425 "type": "boolean"
15426 },
15427 "discriminator": {
15428 "$ref": "#/definitions/discriminator"
15429 },
15430 "readOnly": {
15431 "type": "boolean"
15432 },
15433 "writeOnly": {
15434 "type": "boolean"
15435 },
15436 "xml": {
15437 "$ref": "#/definitions/xml"
15438 },
15439 "externalDocs": {
15440 "$ref": "#/definitions/externalDocs"
15441 },
15442 "example": {
15443 "$ref": "#/definitions/any"
15444 },
15445 "deprecated": {
15446 "type": "boolean"
15447 },
15448 "title": {
15449 "$ref": "http://json-schema.org/draft-04/schema#/properties/title"
15450 },
15451 "multipleOf": {
15452 "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"
15453 },
15454 "maximum": {
15455 "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"
15456 },
15457 "exclusiveMaximum": {
15458 "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
15459 },
15460 "minimum": {
15461 "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"
15462 },
15463 "exclusiveMinimum": {
15464 "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
15465 },
15466 "maxLength": {
15467 "$ref": "http://json-schema.org/draft-04/schema#/properties/maxLength"
15468 },
15469 "minLength": {
15470 "$ref": "http://json-schema.org/draft-04/schema#/properties/minLength"
15471 },
15472 "pattern": {
15473 "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"
15474 },
15475 "maxItems": {
15476 "$ref": "http://json-schema.org/draft-04/schema#/properties/maxItems"
15477 },
15478 "minItems": {
15479 "$ref": "http://json-schema.org/draft-04/schema#/properties/minItems"
15480 },
15481 "uniqueItems": {
15482 "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
15483 },
15484 "maxProperties": {
15485 "$ref": "http://json-schema.org/draft-04/schema#/properties/maxProperties"
15486 },
15487 "minProperties": {
15488 "$ref": "http://json-schema.org/draft-04/schema#/properties/minProperties"
15489 },
15490 "required": {
15491 "$ref": "http://json-schema.org/draft-04/schema#/properties/required"
15492 },
15493 "enum": {
15494 "$ref": "http://json-schema.org/draft-04/schema#/properties/enum"
15495 },
15496 "type": {
15497 "type": "string"
15498 },
15499 "allOf": {
15500 "type": "array",
15501 "items": {
15502 "$ref": "#/definitions/schemaOrReference"
15503 },
15504 "minItems": 1
15505 },
15506 "oneOf": {
15507 "type": "array",
15508 "items": {
15509 "$ref": "#/definitions/schemaOrReference"
15510 },
15511 "minItems": 1
15512 },
15513 "anyOf": {
15514 "type": "array",
15515 "items": {
15516 "$ref": "#/definitions/schemaOrReference"
15517 },
15518 "minItems": 1
15519 },
15520 "not": {
15521 "$ref": "#/definitions/schema"
15522 },
15523 "items": {
15524 "anyOf": [
15525 {
15526 "$ref": "#/definitions/schemaOrReference"
15527 },
15528 {
15529 "type": "array",
15530 "items": {
15531 "$ref": "#/definitions/schemaOrReference"
15532 },
15533 "minItems": 1
15534 }
15535 ]
15536 },
15537 "properties": {
15538 "type": "object",
15539 "additionalProperties": {
15540 "$ref": "#/definitions/schemaOrReference"
15541 }
15542 },
15543 "additionalProperties": {
15544 "oneOf": [
15545 {
15546 "$ref": "#/definitions/schemaOrReference"
15547 },
15548 {
15549 "type": "boolean"
15550 }
15551 ]
15552 },
15553 "default": {
15554 "$ref": "#/definitions/defaultType"
15555 },
15556 "description": {
15557 "type": "string"
15558 },
15559 "format": {
15560 "type": "string"
15561 }
15562 }
15563 },
15564 "discriminator": {
15565 "type": "object",
15566 "description": "When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. When using the discriminator, _inline_ schemas will not be considered.",
15567 "required": [
15568 "propertyName"
15569 ],
15570 "additionalProperties": false,
15571 "properties": {
15572 "propertyName": {
15573 "type": "string"
15574 },
15575 "mapping": {
15576 "$ref": "#/definitions/strings"
15577 }
15578 }
15579 },
15580 "xml": {
15581 "type": "object",
15582 "description": "A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior.",
15583 "additionalProperties": false,
15584 "patternProperties": {
15585 "^x-": {
15586 "$ref": "#/definitions/specificationExtension"
15587 }
15588 },
15589 "properties": {
15590 "name": {
15591 "type": "string"
15592 },
15593 "namespace": {
15594 "type": "string"
15595 },
15596 "prefix": {
15597 "type": "string"
15598 },
15599 "attribute": {
15600 "type": "boolean"
15601 },
15602 "wrapped": {
15603 "type": "boolean"
15604 }
15605 }
15606 },
15607 "securityScheme": {
15608 "type": "object",
15609 "description": "Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header or as a query parameter), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and OpenID Connect Discovery.",
15610 "required": [
15611 "type"
15612 ],
15613 "additionalProperties": false,
15614 "patternProperties": {
15615 "^x-": {
15616 "$ref": "#/definitions/specificationExtension"
15617 }
15618 },
15619 "properties": {
15620 "type": {
15621 "type": "string"
15622 },
15623 "description": {
15624 "type": "string"
15625 },
15626 "name": {
15627 "type": "string"
15628 },
15629 "in": {
15630 "type": "string"
15631 },
15632 "scheme": {
15633 "type": "string"
15634 },
15635 "bearerFormat": {
15636 "type": "string"
15637 },
15638 "flows": {
15639 "$ref": "#/definitions/oauthFlows"
15640 },
15641 "openIdConnectUrl": {
15642 "type": "string"
15643 }
15644 }
15645 },
15646 "oauthFlows": {
15647 "type": "object",
15648 "description": "Allows configuration of the supported OAuth Flows.",
15649 "additionalProperties": false,
15650 "patternProperties": {
15651 "^x-": {
15652 "$ref": "#/definitions/specificationExtension"
15653 }
15654 },
15655 "properties": {
15656 "implicit": {
15657 "$ref": "#/definitions/oauthFlow"
15658 },
15659 "password": {
15660 "$ref": "#/definitions/oauthFlow"
15661 },
15662 "clientCredentials": {
15663 "$ref": "#/definitions/oauthFlow"
15664 },
15665 "authorizationCode": {
15666 "$ref": "#/definitions/oauthFlow"
15667 }
15668 }
15669 },
15670 "oauthFlow": {
15671 "type": "object",
15672 "description": "Configuration details for a supported OAuth Flow",
15673 "additionalProperties": false,
15674 "patternProperties": {
15675 "^x-": {
15676 "$ref": "#/definitions/specificationExtension"
15677 }
15678 },
15679 "properties": {
15680 "authorizationUrl": {
15681 "type": "string"
15682 },
15683 "tokenUrl": {
15684 "type": "string"
15685 },
15686 "refreshUrl": {
15687 "type": "string"
15688 },
15689 "scopes": {
15690 "$ref": "#/definitions/strings"
15691 }
15692 }
15693 },
15694 "securityRequirement": {
15695 "type": "object",
15696 "description": "Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object. Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. When a list of Security Requirement Objects is defined on the Open API object or Operation Object, only one of Security Requirement Objects in the list needs to be satisfied to authorize the request.",
15697 "additionalProperties": false,
15698 "patternProperties": {
15699 "^[a-zA-Z0-9\\.\\-_]+$": {
15700 "type": "array",
15701 "items": {
15702 "type": "string"
15703 },
15704 "uniqueItems": true
15705 }
15706 }
15707 },
15708 "anyOrExpression": {
15709 "oneOf": [
15710 {
15711 "$ref": "#/definitions/any"
15712 },
15713 {
15714 "$ref": "#/definitions/expression"
15715 }
15716 ]
15717 },
15718 "callbackOrReference": {
15719 "oneOf": [
15720 {
15721 "$ref": "#/definitions/callback"
15722 },
15723 {
15724 "$ref": "#/definitions/reference"
15725 }
15726 ]
15727 },
15728 "exampleOrReference": {
15729 "oneOf": [
15730 {
15731 "$ref": "#/definitions/example"
15732 },
15733 {
15734 "$ref": "#/definitions/reference"
15735 }
15736 ]
15737 },
15738 "headerOrReference": {
15739 "oneOf": [
15740 {
15741 "$ref": "#/definitions/header"
15742 },
15743 {
15744 "$ref": "#/definitions/reference"
15745 }
15746 ]
15747 },
15748 "linkOrReference": {
15749 "oneOf": [
15750 {
15751 "$ref": "#/definitions/link"
15752 },
15753 {
15754 "$ref": "#/definitions/reference"
15755 }
15756 ]
15757 },
15758 "parameterOrReference": {
15759 "oneOf": [
15760 {
15761 "$ref": "#/definitions/parameter"
15762 },
15763 {
15764 "$ref": "#/definitions/reference"
15765 }
15766 ]
15767 },
15768 "requestBodyOrReference": {
15769 "oneOf": [
15770 {
15771 "$ref": "#/definitions/requestBody"
15772 },
15773 {
15774 "$ref": "#/definitions/reference"
15775 }
15776 ]
15777 },
15778 "responseOrReference": {
15779 "oneOf": [
15780 {
15781 "$ref": "#/definitions/response"
15782 },
15783 {
15784 "$ref": "#/definitions/reference"
15785 }
15786 ]
15787 },
15788 "schemaOrReference": {
15789 "oneOf": [
15790 {
15791 "$ref": "#/definitions/schema"
15792 },
15793 {
15794 "$ref": "#/definitions/reference"
15795 }
15796 ]
15797 },
15798 "securitySchemeOrReference": {
15799 "oneOf": [
15800 {
15801 "$ref": "#/definitions/securityScheme"
15802 },
15803 {
15804 "$ref": "#/definitions/reference"
15805 }
15806 ]
15807 },
15808 "anysOrExpressions": {
15809 "type": "object",
15810 "additionalProperties": {
15811 "$ref": "#/definitions/anyOrExpression"
15812 }
15813 },
15814 "callbacksOrReferences": {
15815 "type": "object",
15816 "additionalProperties": {
15817 "$ref": "#/definitions/callbackOrReference"
15818 }
15819 },
15820 "encodings": {
15821 "type": "object",
15822 "additionalProperties": {
15823 "$ref": "#/definitions/encoding"
15824 }
15825 },
15826 "examplesOrReferences": {
15827 "type": "object",
15828 "additionalProperties": {
15829 "$ref": "#/definitions/exampleOrReference"
15830 }
15831 },
15832 "headersOrReferences": {
15833 "type": "object",
15834 "additionalProperties": {
15835 "$ref": "#/definitions/headerOrReference"
15836 }
15837 },
15838 "linksOrReferences": {
15839 "type": "object",
15840 "additionalProperties": {
15841 "$ref": "#/definitions/linkOrReference"
15842 }
15843 },
15844 "mediaTypes": {
15845 "type": "object",
15846 "additionalProperties": {
15847 "$ref": "#/definitions/mediaType"
15848 }
15849 },
15850 "parametersOrReferences": {
15851 "type": "object",
15852 "additionalProperties": {
15853 "$ref": "#/definitions/parameterOrReference"
15854 }
15855 },
15856 "requestBodiesOrReferences": {
15857 "type": "object",
15858 "additionalProperties": {
15859 "$ref": "#/definitions/requestBodyOrReference"
15860 }
15861 },
15862 "responsesOrReferences": {
15863 "type": "object",
15864 "additionalProperties": {
15865 "$ref": "#/definitions/responseOrReference"
15866 }
15867 },
15868 "schemasOrReferences": {
15869 "type": "object",
15870 "additionalProperties": {
15871 "$ref": "#/definitions/schemaOrReference"
15872 }
15873 },
15874 "securitySchemesOrReferences": {
15875 "type": "object",
15876 "additionalProperties": {
15877 "$ref": "#/definitions/securitySchemeOrReference"
15878 }
15879 },
15880 "serverVariables": {
15881 "type": "object",
15882 "additionalProperties": {
15883 "$ref": "#/definitions/serverVariable"
15884 }
15885 },
15886 "strings": {
15887 "type": "object",
15888 "additionalProperties": {
15889 "type": "string"
15890 }
15891 },
15892 "object": {
15893 "type": "object",
15894 "additionalProperties": true
15895 },
15896 "any": {
15897 "additionalProperties": true
15898 },
15899 "expression": {
15900 "type": "object",
15901 "additionalProperties": true
15902 },
15903 "specificationExtension": {
15904 "description": "Any property starting with x- is valid.",
15905 "oneOf": [
15906 {
15907 "type": "null"
15908 },
15909 {
15910 "type": "number"
15911 },
15912 {
15913 "type": "boolean"
15914 },
15915 {
15916 "type": "string"
15917 },
15918 {
15919 "type": "object"
15920 },
15921 {
15922 "type": "array"
15923 }
15924 ]
15925 },
15926 "defaultType": {
15927 "oneOf": [
15928 {
15929 "type": "null"
15930 },
15931 {
15932 "type": "array"
15933 },
15934 {
15935 "type": "object"
15936 },
15937 {
15938 "type": "number"
15939 },
15940 {
15941 "type": "boolean"
15942 },
15943 {
15944 "type": "string"
15945 }
15946 ]
15947 }
15948 }
15949}
15950
15951},{}],124:[function(require,module,exports){
15952(function (process){
15953'use strict';
15954
15955if (!process.version ||
15956 process.version.indexOf('v0.') === 0 ||
15957 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
15958 module.exports = { nextTick: nextTick };
15959} else {
15960 module.exports = process
15961}
15962
15963function nextTick(fn, arg1, arg2, arg3) {
15964 if (typeof fn !== 'function') {
15965 throw new TypeError('"callback" argument must be a function');
15966 }
15967 var len = arguments.length;
15968 var args, i;
15969 switch (len) {
15970 case 0:
15971 case 1:
15972 return process.nextTick(fn);
15973 case 2:
15974 return process.nextTick(function afterTickOne() {
15975 fn.call(null, arg1);
15976 });
15977 case 3:
15978 return process.nextTick(function afterTickTwo() {
15979 fn.call(null, arg1, arg2);
15980 });
15981 case 4:
15982 return process.nextTick(function afterTickThree() {
15983 fn.call(null, arg1, arg2, arg3);
15984 });
15985 default:
15986 args = new Array(len - 1);
15987 i = 0;
15988 while (i < args.length) {
15989 args[i++] = arguments[i];
15990 }
15991 return process.nextTick(function afterTick() {
15992 fn.apply(null, args);
15993 });
15994 }
15995}
15996
15997
15998}).call(this,require('_process'))
15999
16000},{"_process":125}],125:[function(require,module,exports){
16001// shim for using process in browser
16002var process = module.exports = {};
16003
16004// cached from whatever global is present so that test runners that stub it
16005// don't break things. But we need to wrap it in a try catch in case it is
16006// wrapped in strict mode code which doesn't define any globals. It's inside a
16007// function because try/catches deoptimize in certain engines.
16008
16009var cachedSetTimeout;
16010var cachedClearTimeout;
16011
16012function defaultSetTimout() {
16013 throw new Error('setTimeout has not been defined');
16014}
16015function defaultClearTimeout () {
16016 throw new Error('clearTimeout has not been defined');
16017}
16018(function () {
16019 try {
16020 if (typeof setTimeout === 'function') {
16021 cachedSetTimeout = setTimeout;
16022 } else {
16023 cachedSetTimeout = defaultSetTimout;
16024 }
16025 } catch (e) {
16026 cachedSetTimeout = defaultSetTimout;
16027 }
16028 try {
16029 if (typeof clearTimeout === 'function') {
16030 cachedClearTimeout = clearTimeout;
16031 } else {
16032 cachedClearTimeout = defaultClearTimeout;
16033 }
16034 } catch (e) {
16035 cachedClearTimeout = defaultClearTimeout;
16036 }
16037} ())
16038function runTimeout(fun) {
16039 if (cachedSetTimeout === setTimeout) {
16040 //normal enviroments in sane situations
16041 return setTimeout(fun, 0);
16042 }
16043 // if setTimeout wasn't available but was latter defined
16044 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
16045 cachedSetTimeout = setTimeout;
16046 return setTimeout(fun, 0);
16047 }
16048 try {
16049 // when when somebody has screwed with setTimeout but no I.E. maddness
16050 return cachedSetTimeout(fun, 0);
16051 } catch(e){
16052 try {
16053 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
16054 return cachedSetTimeout.call(null, fun, 0);
16055 } catch(e){
16056 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
16057 return cachedSetTimeout.call(this, fun, 0);
16058 }
16059 }
16060
16061
16062}
16063function runClearTimeout(marker) {
16064 if (cachedClearTimeout === clearTimeout) {
16065 //normal enviroments in sane situations
16066 return clearTimeout(marker);
16067 }
16068 // if clearTimeout wasn't available but was latter defined
16069 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
16070 cachedClearTimeout = clearTimeout;
16071 return clearTimeout(marker);
16072 }
16073 try {
16074 // when when somebody has screwed with setTimeout but no I.E. maddness
16075 return cachedClearTimeout(marker);
16076 } catch (e){
16077 try {
16078 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
16079 return cachedClearTimeout.call(null, marker);
16080 } catch (e){
16081 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
16082 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
16083 return cachedClearTimeout.call(this, marker);
16084 }
16085 }
16086
16087
16088
16089}
16090var queue = [];
16091var draining = false;
16092var currentQueue;
16093var queueIndex = -1;
16094
16095function cleanUpNextTick() {
16096 if (!draining || !currentQueue) {
16097 return;
16098 }
16099 draining = false;
16100 if (currentQueue.length) {
16101 queue = currentQueue.concat(queue);
16102 } else {
16103 queueIndex = -1;
16104 }
16105 if (queue.length) {
16106 drainQueue();
16107 }
16108}
16109
16110function drainQueue() {
16111 if (draining) {
16112 return;
16113 }
16114 var timeout = runTimeout(cleanUpNextTick);
16115 draining = true;
16116
16117 var len = queue.length;
16118 while(len) {
16119 currentQueue = queue;
16120 queue = [];
16121 while (++queueIndex < len) {
16122 if (currentQueue) {
16123 currentQueue[queueIndex].run();
16124 }
16125 }
16126 queueIndex = -1;
16127 len = queue.length;
16128 }
16129 currentQueue = null;
16130 draining = false;
16131 runClearTimeout(timeout);
16132}
16133
16134process.nextTick = function (fun) {
16135 var args = new Array(arguments.length - 1);
16136 if (arguments.length > 1) {
16137 for (var i = 1; i < arguments.length; i++) {
16138 args[i - 1] = arguments[i];
16139 }
16140 }
16141 queue.push(new Item(fun, args));
16142 if (queue.length === 1 && !draining) {
16143 runTimeout(drainQueue);
16144 }
16145};
16146
16147// v8 likes predictible objects
16148function Item(fun, array) {
16149 this.fun = fun;
16150 this.array = array;
16151}
16152Item.prototype.run = function () {
16153 this.fun.apply(null, this.array);
16154};
16155process.title = 'browser';
16156process.browser = true;
16157process.env = {};
16158process.argv = [];
16159process.version = ''; // empty string to avoid regexp issues
16160process.versions = {};
16161
16162function noop() {}
16163
16164process.on = noop;
16165process.addListener = noop;
16166process.once = noop;
16167process.off = noop;
16168process.removeListener = noop;
16169process.removeAllListeners = noop;
16170process.emit = noop;
16171process.prependListener = noop;
16172process.prependOnceListener = noop;
16173
16174process.listeners = function (name) { return [] }
16175
16176process.binding = function (name) {
16177 throw new Error('process.binding is not supported');
16178};
16179
16180process.cwd = function () { return '/' };
16181process.chdir = function (dir) {
16182 throw new Error('process.chdir is not supported');
16183};
16184process.umask = function() { return 0; };
16185
16186},{}],126:[function(require,module,exports){
16187// Copyright Joyent, Inc. and other Node contributors.
16188//
16189// Permission is hereby granted, free of charge, to any person obtaining a
16190// copy of this software and associated documentation files (the
16191// "Software"), to deal in the Software without restriction, including
16192// without limitation the rights to use, copy, modify, merge, publish,
16193// distribute, sublicense, and/or sell copies of the Software, and to permit
16194// persons to whom the Software is furnished to do so, subject to the
16195// following conditions:
16196//
16197// The above copyright notice and this permission notice shall be included
16198// in all copies or substantial portions of the Software.
16199//
16200// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16201// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16202// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16203// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16204// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16205// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16206// USE OR OTHER DEALINGS IN THE SOFTWARE.
16207
16208'use strict';
16209
16210// If obj.hasOwnProperty has been overridden, then calling
16211// obj.hasOwnProperty(prop) will break.
16212// See: https://github.com/joyent/node/issues/1707
16213function hasOwnProperty(obj, prop) {
16214 return Object.prototype.hasOwnProperty.call(obj, prop);
16215}
16216
16217module.exports = function(qs, sep, eq, options) {
16218 sep = sep || '&';
16219 eq = eq || '=';
16220 var obj = {};
16221
16222 if (typeof qs !== 'string' || qs.length === 0) {
16223 return obj;
16224 }
16225
16226 var regexp = /\+/g;
16227 qs = qs.split(sep);
16228
16229 var maxKeys = 1000;
16230 if (options && typeof options.maxKeys === 'number') {
16231 maxKeys = options.maxKeys;
16232 }
16233
16234 var len = qs.length;
16235 // maxKeys <= 0 means that we should not limit keys count
16236 if (maxKeys > 0 && len > maxKeys) {
16237 len = maxKeys;
16238 }
16239
16240 for (var i = 0; i < len; ++i) {
16241 var x = qs[i].replace(regexp, '%20'),
16242 idx = x.indexOf(eq),
16243 kstr, vstr, k, v;
16244
16245 if (idx >= 0) {
16246 kstr = x.substr(0, idx);
16247 vstr = x.substr(idx + 1);
16248 } else {
16249 kstr = x;
16250 vstr = '';
16251 }
16252
16253 k = decodeURIComponent(kstr);
16254 v = decodeURIComponent(vstr);
16255
16256 if (!hasOwnProperty(obj, k)) {
16257 obj[k] = v;
16258 } else if (isArray(obj[k])) {
16259 obj[k].push(v);
16260 } else {
16261 obj[k] = [obj[k], v];
16262 }
16263 }
16264
16265 return obj;
16266};
16267
16268var isArray = Array.isArray || function (xs) {
16269 return Object.prototype.toString.call(xs) === '[object Array]';
16270};
16271
16272},{}],127:[function(require,module,exports){
16273// Copyright Joyent, Inc. and other Node contributors.
16274//
16275// Permission is hereby granted, free of charge, to any person obtaining a
16276// copy of this software and associated documentation files (the
16277// "Software"), to deal in the Software without restriction, including
16278// without limitation the rights to use, copy, modify, merge, publish,
16279// distribute, sublicense, and/or sell copies of the Software, and to permit
16280// persons to whom the Software is furnished to do so, subject to the
16281// following conditions:
16282//
16283// The above copyright notice and this permission notice shall be included
16284// in all copies or substantial portions of the Software.
16285//
16286// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16287// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16288// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16289// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16290// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16291// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16292// USE OR OTHER DEALINGS IN THE SOFTWARE.
16293
16294'use strict';
16295
16296var stringifyPrimitive = function(v) {
16297 switch (typeof v) {
16298 case 'string':
16299 return v;
16300
16301 case 'boolean':
16302 return v ? 'true' : 'false';
16303
16304 case 'number':
16305 return isFinite(v) ? v : '';
16306
16307 default:
16308 return '';
16309 }
16310};
16311
16312module.exports = function(obj, sep, eq, name) {
16313 sep = sep || '&';
16314 eq = eq || '=';
16315 if (obj === null) {
16316 obj = undefined;
16317 }
16318
16319 if (typeof obj === 'object') {
16320 return map(objectKeys(obj), function(k) {
16321 var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
16322 if (isArray(obj[k])) {
16323 return map(obj[k], function(v) {
16324 return ks + encodeURIComponent(stringifyPrimitive(v));
16325 }).join(sep);
16326 } else {
16327 return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
16328 }
16329 }).join(sep);
16330
16331 }
16332
16333 if (!name) return '';
16334 return encodeURIComponent(stringifyPrimitive(name)) + eq +
16335 encodeURIComponent(stringifyPrimitive(obj));
16336};
16337
16338var isArray = Array.isArray || function (xs) {
16339 return Object.prototype.toString.call(xs) === '[object Array]';
16340};
16341
16342function map (xs, f) {
16343 if (xs.map) return xs.map(f);
16344 var res = [];
16345 for (var i = 0; i < xs.length; i++) {
16346 res.push(f(xs[i], i));
16347 }
16348 return res;
16349}
16350
16351var objectKeys = Object.keys || function (obj) {
16352 var res = [];
16353 for (var key in obj) {
16354 if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
16355 }
16356 return res;
16357};
16358
16359},{}],128:[function(require,module,exports){
16360'use strict';
16361
16362exports.decode = exports.parse = require('./decode');
16363exports.encode = exports.stringify = require('./encode');
16364
16365},{"./decode":126,"./encode":127}],129:[function(require,module,exports){
16366// Copyright Joyent, Inc. and other Node contributors.
16367//
16368// Permission is hereby granted, free of charge, to any person obtaining a
16369// copy of this software and associated documentation files (the
16370// "Software"), to deal in the Software without restriction, including
16371// without limitation the rights to use, copy, modify, merge, publish,
16372// distribute, sublicense, and/or sell copies of the Software, and to permit
16373// persons to whom the Software is furnished to do so, subject to the
16374// following conditions:
16375//
16376// The above copyright notice and this permission notice shall be included
16377// in all copies or substantial portions of the Software.
16378//
16379// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16380// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16381// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16382// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16383// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16384// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16385// USE OR OTHER DEALINGS IN THE SOFTWARE.
16386
16387// a duplex stream is just a stream that is both readable and writable.
16388// Since JS doesn't have multiple prototypal inheritance, this class
16389// prototypally inherits from Readable, and then parasitically from
16390// Writable.
16391
16392'use strict';
16393
16394/*<replacement>*/
16395
16396var pna = require('process-nextick-args');
16397/*</replacement>*/
16398
16399/*<replacement>*/
16400var objectKeys = Object.keys || function (obj) {
16401 var keys = [];
16402 for (var key in obj) {
16403 keys.push(key);
16404 }return keys;
16405};
16406/*</replacement>*/
16407
16408module.exports = Duplex;
16409
16410/*<replacement>*/
16411var util = require('core-util-is');
16412util.inherits = require('inherits');
16413/*</replacement>*/
16414
16415var Readable = require('./_stream_readable');
16416var Writable = require('./_stream_writable');
16417
16418util.inherits(Duplex, Readable);
16419
16420{
16421 // avoid scope creep, the keys array can then be collected
16422 var keys = objectKeys(Writable.prototype);
16423 for (var v = 0; v < keys.length; v++) {
16424 var method = keys[v];
16425 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
16426 }
16427}
16428
16429function Duplex(options) {
16430 if (!(this instanceof Duplex)) return new Duplex(options);
16431
16432 Readable.call(this, options);
16433 Writable.call(this, options);
16434
16435 if (options && options.readable === false) this.readable = false;
16436
16437 if (options && options.writable === false) this.writable = false;
16438
16439 this.allowHalfOpen = true;
16440 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
16441
16442 this.once('end', onend);
16443}
16444
16445Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
16446 // making it explicit this property is not enumerable
16447 // because otherwise some prototype manipulation in
16448 // userland will fail
16449 enumerable: false,
16450 get: function () {
16451 return this._writableState.highWaterMark;
16452 }
16453});
16454
16455// the no-half-open enforcer
16456function onend() {
16457 // if we allow half-open state, or if the writable side ended,
16458 // then we're ok.
16459 if (this.allowHalfOpen || this._writableState.ended) return;
16460
16461 // no more data can be written.
16462 // But allow more writes to happen in this tick.
16463 pna.nextTick(onEndNT, this);
16464}
16465
16466function onEndNT(self) {
16467 self.end();
16468}
16469
16470Object.defineProperty(Duplex.prototype, 'destroyed', {
16471 get: function () {
16472 if (this._readableState === undefined || this._writableState === undefined) {
16473 return false;
16474 }
16475 return this._readableState.destroyed && this._writableState.destroyed;
16476 },
16477 set: function (value) {
16478 // we ignore the value if the stream
16479 // has not been initialized yet
16480 if (this._readableState === undefined || this._writableState === undefined) {
16481 return;
16482 }
16483
16484 // backward compatibility, the user is explicitly
16485 // managing destroyed
16486 this._readableState.destroyed = value;
16487 this._writableState.destroyed = value;
16488 }
16489});
16490
16491Duplex.prototype._destroy = function (err, cb) {
16492 this.push(null);
16493 this.end();
16494
16495 pna.nextTick(cb, err);
16496};
16497},{"./_stream_readable":131,"./_stream_writable":133,"core-util-is":63,"inherits":68,"process-nextick-args":124}],130:[function(require,module,exports){
16498// Copyright Joyent, Inc. and other Node contributors.
16499//
16500// Permission is hereby granted, free of charge, to any person obtaining a
16501// copy of this software and associated documentation files (the
16502// "Software"), to deal in the Software without restriction, including
16503// without limitation the rights to use, copy, modify, merge, publish,
16504// distribute, sublicense, and/or sell copies of the Software, and to permit
16505// persons to whom the Software is furnished to do so, subject to the
16506// following conditions:
16507//
16508// The above copyright notice and this permission notice shall be included
16509// in all copies or substantial portions of the Software.
16510//
16511// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16512// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16513// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16514// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16515// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16516// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16517// USE OR OTHER DEALINGS IN THE SOFTWARE.
16518
16519// a passthrough stream.
16520// basically just the most minimal sort of Transform stream.
16521// Every written chunk gets output as-is.
16522
16523'use strict';
16524
16525module.exports = PassThrough;
16526
16527var Transform = require('./_stream_transform');
16528
16529/*<replacement>*/
16530var util = require('core-util-is');
16531util.inherits = require('inherits');
16532/*</replacement>*/
16533
16534util.inherits(PassThrough, Transform);
16535
16536function PassThrough(options) {
16537 if (!(this instanceof PassThrough)) return new PassThrough(options);
16538
16539 Transform.call(this, options);
16540}
16541
16542PassThrough.prototype._transform = function (chunk, encoding, cb) {
16543 cb(null, chunk);
16544};
16545},{"./_stream_transform":132,"core-util-is":63,"inherits":68}],131:[function(require,module,exports){
16546(function (process,global){
16547// Copyright Joyent, Inc. and other Node contributors.
16548//
16549// Permission is hereby granted, free of charge, to any person obtaining a
16550// copy of this software and associated documentation files (the
16551// "Software"), to deal in the Software without restriction, including
16552// without limitation the rights to use, copy, modify, merge, publish,
16553// distribute, sublicense, and/or sell copies of the Software, and to permit
16554// persons to whom the Software is furnished to do so, subject to the
16555// following conditions:
16556//
16557// The above copyright notice and this permission notice shall be included
16558// in all copies or substantial portions of the Software.
16559//
16560// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16561// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16562// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16563// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16564// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16565// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16566// USE OR OTHER DEALINGS IN THE SOFTWARE.
16567
16568'use strict';
16569
16570/*<replacement>*/
16571
16572var pna = require('process-nextick-args');
16573/*</replacement>*/
16574
16575module.exports = Readable;
16576
16577/*<replacement>*/
16578var isArray = require('isarray');
16579/*</replacement>*/
16580
16581/*<replacement>*/
16582var Duplex;
16583/*</replacement>*/
16584
16585Readable.ReadableState = ReadableState;
16586
16587/*<replacement>*/
16588var EE = require('events').EventEmitter;
16589
16590var EElistenerCount = function (emitter, type) {
16591 return emitter.listeners(type).length;
16592};
16593/*</replacement>*/
16594
16595/*<replacement>*/
16596var Stream = require('./internal/streams/stream');
16597/*</replacement>*/
16598
16599/*<replacement>*/
16600
16601var Buffer = require('safe-buffer').Buffer;
16602var OurUint8Array = global.Uint8Array || function () {};
16603function _uint8ArrayToBuffer(chunk) {
16604 return Buffer.from(chunk);
16605}
16606function _isUint8Array(obj) {
16607 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
16608}
16609
16610/*</replacement>*/
16611
16612/*<replacement>*/
16613var util = require('core-util-is');
16614util.inherits = require('inherits');
16615/*</replacement>*/
16616
16617/*<replacement>*/
16618var debugUtil = require('util');
16619var debug = void 0;
16620if (debugUtil && debugUtil.debuglog) {
16621 debug = debugUtil.debuglog('stream');
16622} else {
16623 debug = function () {};
16624}
16625/*</replacement>*/
16626
16627var BufferList = require('./internal/streams/BufferList');
16628var destroyImpl = require('./internal/streams/destroy');
16629var StringDecoder;
16630
16631util.inherits(Readable, Stream);
16632
16633var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
16634
16635function prependListener(emitter, event, fn) {
16636 // Sadly this is not cacheable as some libraries bundle their own
16637 // event emitter implementation with them.
16638 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
16639
16640 // This is a hack to make sure that our error handler is attached before any
16641 // userland ones. NEVER DO THIS. This is here only because this code needs
16642 // to continue to work with older versions of Node.js that do not include
16643 // the prependListener() method. The goal is to eventually remove this hack.
16644 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
16645}
16646
16647function ReadableState(options, stream) {
16648 Duplex = Duplex || require('./_stream_duplex');
16649
16650 options = options || {};
16651
16652 // Duplex streams are both readable and writable, but share
16653 // the same options object.
16654 // However, some cases require setting options to different
16655 // values for the readable and the writable sides of the duplex stream.
16656 // These options can be provided separately as readableXXX and writableXXX.
16657 var isDuplex = stream instanceof Duplex;
16658
16659 // object stream flag. Used to make read(n) ignore n and to
16660 // make all the buffer merging and length checks go away
16661 this.objectMode = !!options.objectMode;
16662
16663 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
16664
16665 // the point at which it stops calling _read() to fill the buffer
16666 // Note: 0 is a valid value, means "don't call _read preemptively ever"
16667 var hwm = options.highWaterMark;
16668 var readableHwm = options.readableHighWaterMark;
16669 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
16670
16671 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
16672
16673 // cast to ints.
16674 this.highWaterMark = Math.floor(this.highWaterMark);
16675
16676 // A linked list is used to store data chunks instead of an array because the
16677 // linked list can remove elements from the beginning faster than
16678 // array.shift()
16679 this.buffer = new BufferList();
16680 this.length = 0;
16681 this.pipes = null;
16682 this.pipesCount = 0;
16683 this.flowing = null;
16684 this.ended = false;
16685 this.endEmitted = false;
16686 this.reading = false;
16687
16688 // a flag to be able to tell if the event 'readable'/'data' is emitted
16689 // immediately, or on a later tick. We set this to true at first, because
16690 // any actions that shouldn't happen until "later" should generally also
16691 // not happen before the first read call.
16692 this.sync = true;
16693
16694 // whenever we return null, then we set a flag to say
16695 // that we're awaiting a 'readable' event emission.
16696 this.needReadable = false;
16697 this.emittedReadable = false;
16698 this.readableListening = false;
16699 this.resumeScheduled = false;
16700
16701 // has it been destroyed
16702 this.destroyed = false;
16703
16704 // Crypto is kind of old and crusty. Historically, its default string
16705 // encoding is 'binary' so we have to make this configurable.
16706 // Everything else in the universe uses 'utf8', though.
16707 this.defaultEncoding = options.defaultEncoding || 'utf8';
16708
16709 // the number of writers that are awaiting a drain event in .pipe()s
16710 this.awaitDrain = 0;
16711
16712 // if true, a maybeReadMore has been scheduled
16713 this.readingMore = false;
16714
16715 this.decoder = null;
16716 this.encoding = null;
16717 if (options.encoding) {
16718 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
16719 this.decoder = new StringDecoder(options.encoding);
16720 this.encoding = options.encoding;
16721 }
16722}
16723
16724function Readable(options) {
16725 Duplex = Duplex || require('./_stream_duplex');
16726
16727 if (!(this instanceof Readable)) return new Readable(options);
16728
16729 this._readableState = new ReadableState(options, this);
16730
16731 // legacy
16732 this.readable = true;
16733
16734 if (options) {
16735 if (typeof options.read === 'function') this._read = options.read;
16736
16737 if (typeof options.destroy === 'function') this._destroy = options.destroy;
16738 }
16739
16740 Stream.call(this);
16741}
16742
16743Object.defineProperty(Readable.prototype, 'destroyed', {
16744 get: function () {
16745 if (this._readableState === undefined) {
16746 return false;
16747 }
16748 return this._readableState.destroyed;
16749 },
16750 set: function (value) {
16751 // we ignore the value if the stream
16752 // has not been initialized yet
16753 if (!this._readableState) {
16754 return;
16755 }
16756
16757 // backward compatibility, the user is explicitly
16758 // managing destroyed
16759 this._readableState.destroyed = value;
16760 }
16761});
16762
16763Readable.prototype.destroy = destroyImpl.destroy;
16764Readable.prototype._undestroy = destroyImpl.undestroy;
16765Readable.prototype._destroy = function (err, cb) {
16766 this.push(null);
16767 cb(err);
16768};
16769
16770// Manually shove something into the read() buffer.
16771// This returns true if the highWaterMark has not been hit yet,
16772// similar to how Writable.write() returns true if you should
16773// write() some more.
16774Readable.prototype.push = function (chunk, encoding) {
16775 var state = this._readableState;
16776 var skipChunkCheck;
16777
16778 if (!state.objectMode) {
16779 if (typeof chunk === 'string') {
16780 encoding = encoding || state.defaultEncoding;
16781 if (encoding !== state.encoding) {
16782 chunk = Buffer.from(chunk, encoding);
16783 encoding = '';
16784 }
16785 skipChunkCheck = true;
16786 }
16787 } else {
16788 skipChunkCheck = true;
16789 }
16790
16791 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
16792};
16793
16794// Unshift should *always* be something directly out of read()
16795Readable.prototype.unshift = function (chunk) {
16796 return readableAddChunk(this, chunk, null, true, false);
16797};
16798
16799function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
16800 var state = stream._readableState;
16801 if (chunk === null) {
16802 state.reading = false;
16803 onEofChunk(stream, state);
16804 } else {
16805 var er;
16806 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
16807 if (er) {
16808 stream.emit('error', er);
16809 } else if (state.objectMode || chunk && chunk.length > 0) {
16810 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
16811 chunk = _uint8ArrayToBuffer(chunk);
16812 }
16813
16814 if (addToFront) {
16815 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
16816 } else if (state.ended) {
16817 stream.emit('error', new Error('stream.push() after EOF'));
16818 } else {
16819 state.reading = false;
16820 if (state.decoder && !encoding) {
16821 chunk = state.decoder.write(chunk);
16822 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
16823 } else {
16824 addChunk(stream, state, chunk, false);
16825 }
16826 }
16827 } else if (!addToFront) {
16828 state.reading = false;
16829 }
16830 }
16831
16832 return needMoreData(state);
16833}
16834
16835function addChunk(stream, state, chunk, addToFront) {
16836 if (state.flowing && state.length === 0 && !state.sync) {
16837 stream.emit('data', chunk);
16838 stream.read(0);
16839 } else {
16840 // update the buffer info.
16841 state.length += state.objectMode ? 1 : chunk.length;
16842 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
16843
16844 if (state.needReadable) emitReadable(stream);
16845 }
16846 maybeReadMore(stream, state);
16847}
16848
16849function chunkInvalid(state, chunk) {
16850 var er;
16851 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
16852 er = new TypeError('Invalid non-string/buffer chunk');
16853 }
16854 return er;
16855}
16856
16857// if it's past the high water mark, we can push in some more.
16858// Also, if we have no data yet, we can stand some
16859// more bytes. This is to work around cases where hwm=0,
16860// such as the repl. Also, if the push() triggered a
16861// readable event, and the user called read(largeNumber) such that
16862// needReadable was set, then we ought to push more, so that another
16863// 'readable' event will be triggered.
16864function needMoreData(state) {
16865 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
16866}
16867
16868Readable.prototype.isPaused = function () {
16869 return this._readableState.flowing === false;
16870};
16871
16872// backwards compatibility.
16873Readable.prototype.setEncoding = function (enc) {
16874 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
16875 this._readableState.decoder = new StringDecoder(enc);
16876 this._readableState.encoding = enc;
16877 return this;
16878};
16879
16880// Don't raise the hwm > 8MB
16881var MAX_HWM = 0x800000;
16882function computeNewHighWaterMark(n) {
16883 if (n >= MAX_HWM) {
16884 n = MAX_HWM;
16885 } else {
16886 // Get the next highest power of 2 to prevent increasing hwm excessively in
16887 // tiny amounts
16888 n--;
16889 n |= n >>> 1;
16890 n |= n >>> 2;
16891 n |= n >>> 4;
16892 n |= n >>> 8;
16893 n |= n >>> 16;
16894 n++;
16895 }
16896 return n;
16897}
16898
16899// This function is designed to be inlinable, so please take care when making
16900// changes to the function body.
16901function howMuchToRead(n, state) {
16902 if (n <= 0 || state.length === 0 && state.ended) return 0;
16903 if (state.objectMode) return 1;
16904 if (n !== n) {
16905 // Only flow one buffer at a time
16906 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
16907 }
16908 // If we're asking for more than the current hwm, then raise the hwm.
16909 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
16910 if (n <= state.length) return n;
16911 // Don't have enough
16912 if (!state.ended) {
16913 state.needReadable = true;
16914 return 0;
16915 }
16916 return state.length;
16917}
16918
16919// you can override either this method, or the async _read(n) below.
16920Readable.prototype.read = function (n) {
16921 debug('read', n);
16922 n = parseInt(n, 10);
16923 var state = this._readableState;
16924 var nOrig = n;
16925
16926 if (n !== 0) state.emittedReadable = false;
16927
16928 // if we're doing read(0) to trigger a readable event, but we
16929 // already have a bunch of data in the buffer, then just trigger
16930 // the 'readable' event and move on.
16931 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
16932 debug('read: emitReadable', state.length, state.ended);
16933 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
16934 return null;
16935 }
16936
16937 n = howMuchToRead(n, state);
16938
16939 // if we've ended, and we're now clear, then finish it up.
16940 if (n === 0 && state.ended) {
16941 if (state.length === 0) endReadable(this);
16942 return null;
16943 }
16944
16945 // All the actual chunk generation logic needs to be
16946 // *below* the call to _read. The reason is that in certain
16947 // synthetic stream cases, such as passthrough streams, _read
16948 // may be a completely synchronous operation which may change
16949 // the state of the read buffer, providing enough data when
16950 // before there was *not* enough.
16951 //
16952 // So, the steps are:
16953 // 1. Figure out what the state of things will be after we do
16954 // a read from the buffer.
16955 //
16956 // 2. If that resulting state will trigger a _read, then call _read.
16957 // Note that this may be asynchronous, or synchronous. Yes, it is
16958 // deeply ugly to write APIs this way, but that still doesn't mean
16959 // that the Readable class should behave improperly, as streams are
16960 // designed to be sync/async agnostic.
16961 // Take note if the _read call is sync or async (ie, if the read call
16962 // has returned yet), so that we know whether or not it's safe to emit
16963 // 'readable' etc.
16964 //
16965 // 3. Actually pull the requested chunks out of the buffer and return.
16966
16967 // if we need a readable event, then we need to do some reading.
16968 var doRead = state.needReadable;
16969 debug('need readable', doRead);
16970
16971 // if we currently have less than the highWaterMark, then also read some
16972 if (state.length === 0 || state.length - n < state.highWaterMark) {
16973 doRead = true;
16974 debug('length less than watermark', doRead);
16975 }
16976
16977 // however, if we've ended, then there's no point, and if we're already
16978 // reading, then it's unnecessary.
16979 if (state.ended || state.reading) {
16980 doRead = false;
16981 debug('reading or ended', doRead);
16982 } else if (doRead) {
16983 debug('do read');
16984 state.reading = true;
16985 state.sync = true;
16986 // if the length is currently zero, then we *need* a readable event.
16987 if (state.length === 0) state.needReadable = true;
16988 // call internal read method
16989 this._read(state.highWaterMark);
16990 state.sync = false;
16991 // If _read pushed data synchronously, then `reading` will be false,
16992 // and we need to re-evaluate how much data we can return to the user.
16993 if (!state.reading) n = howMuchToRead(nOrig, state);
16994 }
16995
16996 var ret;
16997 if (n > 0) ret = fromList(n, state);else ret = null;
16998
16999 if (ret === null) {
17000 state.needReadable = true;
17001 n = 0;
17002 } else {
17003 state.length -= n;
17004 }
17005
17006 if (state.length === 0) {
17007 // If we have nothing in the buffer, then we want to know
17008 // as soon as we *do* get something into the buffer.
17009 if (!state.ended) state.needReadable = true;
17010
17011 // If we tried to read() past the EOF, then emit end on the next tick.
17012 if (nOrig !== n && state.ended) endReadable(this);
17013 }
17014
17015 if (ret !== null) this.emit('data', ret);
17016
17017 return ret;
17018};
17019
17020function onEofChunk(stream, state) {
17021 if (state.ended) return;
17022 if (state.decoder) {
17023 var chunk = state.decoder.end();
17024 if (chunk && chunk.length) {
17025 state.buffer.push(chunk);
17026 state.length += state.objectMode ? 1 : chunk.length;
17027 }
17028 }
17029 state.ended = true;
17030
17031 // emit 'readable' now to make sure it gets picked up.
17032 emitReadable(stream);
17033}
17034
17035// Don't emit readable right away in sync mode, because this can trigger
17036// another read() call => stack overflow. This way, it might trigger
17037// a nextTick recursion warning, but that's not so bad.
17038function emitReadable(stream) {
17039 var state = stream._readableState;
17040 state.needReadable = false;
17041 if (!state.emittedReadable) {
17042 debug('emitReadable', state.flowing);
17043 state.emittedReadable = true;
17044 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
17045 }
17046}
17047
17048function emitReadable_(stream) {
17049 debug('emit readable');
17050 stream.emit('readable');
17051 flow(stream);
17052}
17053
17054// at this point, the user has presumably seen the 'readable' event,
17055// and called read() to consume some data. that may have triggered
17056// in turn another _read(n) call, in which case reading = true if
17057// it's in progress.
17058// However, if we're not ended, or reading, and the length < hwm,
17059// then go ahead and try to read some more preemptively.
17060function maybeReadMore(stream, state) {
17061 if (!state.readingMore) {
17062 state.readingMore = true;
17063 pna.nextTick(maybeReadMore_, stream, state);
17064 }
17065}
17066
17067function maybeReadMore_(stream, state) {
17068 var len = state.length;
17069 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
17070 debug('maybeReadMore read 0');
17071 stream.read(0);
17072 if (len === state.length)
17073 // didn't get any data, stop spinning.
17074 break;else len = state.length;
17075 }
17076 state.readingMore = false;
17077}
17078
17079// abstract method. to be overridden in specific implementation classes.
17080// call cb(er, data) where data is <= n in length.
17081// for virtual (non-string, non-buffer) streams, "length" is somewhat
17082// arbitrary, and perhaps not very meaningful.
17083Readable.prototype._read = function (n) {
17084 this.emit('error', new Error('_read() is not implemented'));
17085};
17086
17087Readable.prototype.pipe = function (dest, pipeOpts) {
17088 var src = this;
17089 var state = this._readableState;
17090
17091 switch (state.pipesCount) {
17092 case 0:
17093 state.pipes = dest;
17094 break;
17095 case 1:
17096 state.pipes = [state.pipes, dest];
17097 break;
17098 default:
17099 state.pipes.push(dest);
17100 break;
17101 }
17102 state.pipesCount += 1;
17103 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
17104
17105 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
17106
17107 var endFn = doEnd ? onend : unpipe;
17108 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
17109
17110 dest.on('unpipe', onunpipe);
17111 function onunpipe(readable, unpipeInfo) {
17112 debug('onunpipe');
17113 if (readable === src) {
17114 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
17115 unpipeInfo.hasUnpiped = true;
17116 cleanup();
17117 }
17118 }
17119 }
17120
17121 function onend() {
17122 debug('onend');
17123 dest.end();
17124 }
17125
17126 // when the dest drains, it reduces the awaitDrain counter
17127 // on the source. This would be more elegant with a .once()
17128 // handler in flow(), but adding and removing repeatedly is
17129 // too slow.
17130 var ondrain = pipeOnDrain(src);
17131 dest.on('drain', ondrain);
17132
17133 var cleanedUp = false;
17134 function cleanup() {
17135 debug('cleanup');
17136 // cleanup event handlers once the pipe is broken
17137 dest.removeListener('close', onclose);
17138 dest.removeListener('finish', onfinish);
17139 dest.removeListener('drain', ondrain);
17140 dest.removeListener('error', onerror);
17141 dest.removeListener('unpipe', onunpipe);
17142 src.removeListener('end', onend);
17143 src.removeListener('end', unpipe);
17144 src.removeListener('data', ondata);
17145
17146 cleanedUp = true;
17147
17148 // if the reader is waiting for a drain event from this
17149 // specific writer, then it would cause it to never start
17150 // flowing again.
17151 // So, if this is awaiting a drain, then we just call it now.
17152 // If we don't know, then assume that we are waiting for one.
17153 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
17154 }
17155
17156 // If the user pushes more data while we're writing to dest then we'll end up
17157 // in ondata again. However, we only want to increase awaitDrain once because
17158 // dest will only emit one 'drain' event for the multiple writes.
17159 // => Introduce a guard on increasing awaitDrain.
17160 var increasedAwaitDrain = false;
17161 src.on('data', ondata);
17162 function ondata(chunk) {
17163 debug('ondata');
17164 increasedAwaitDrain = false;
17165 var ret = dest.write(chunk);
17166 if (false === ret && !increasedAwaitDrain) {
17167 // If the user unpiped during `dest.write()`, it is possible
17168 // to get stuck in a permanently paused state if that write
17169 // also returned false.
17170 // => Check whether `dest` is still a piping destination.
17171 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
17172 debug('false write response, pause', src._readableState.awaitDrain);
17173 src._readableState.awaitDrain++;
17174 increasedAwaitDrain = true;
17175 }
17176 src.pause();
17177 }
17178 }
17179
17180 // if the dest has an error, then stop piping into it.
17181 // however, don't suppress the throwing behavior for this.
17182 function onerror(er) {
17183 debug('onerror', er);
17184 unpipe();
17185 dest.removeListener('error', onerror);
17186 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
17187 }
17188
17189 // Make sure our error handler is attached before userland ones.
17190 prependListener(dest, 'error', onerror);
17191
17192 // Both close and finish should trigger unpipe, but only once.
17193 function onclose() {
17194 dest.removeListener('finish', onfinish);
17195 unpipe();
17196 }
17197 dest.once('close', onclose);
17198 function onfinish() {
17199 debug('onfinish');
17200 dest.removeListener('close', onclose);
17201 unpipe();
17202 }
17203 dest.once('finish', onfinish);
17204
17205 function unpipe() {
17206 debug('unpipe');
17207 src.unpipe(dest);
17208 }
17209
17210 // tell the dest that it's being piped to
17211 dest.emit('pipe', src);
17212
17213 // start the flow if it hasn't been started already.
17214 if (!state.flowing) {
17215 debug('pipe resume');
17216 src.resume();
17217 }
17218
17219 return dest;
17220};
17221
17222function pipeOnDrain(src) {
17223 return function () {
17224 var state = src._readableState;
17225 debug('pipeOnDrain', state.awaitDrain);
17226 if (state.awaitDrain) state.awaitDrain--;
17227 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
17228 state.flowing = true;
17229 flow(src);
17230 }
17231 };
17232}
17233
17234Readable.prototype.unpipe = function (dest) {
17235 var state = this._readableState;
17236 var unpipeInfo = { hasUnpiped: false };
17237
17238 // if we're not piping anywhere, then do nothing.
17239 if (state.pipesCount === 0) return this;
17240
17241 // just one destination. most common case.
17242 if (state.pipesCount === 1) {
17243 // passed in one, but it's not the right one.
17244 if (dest && dest !== state.pipes) return this;
17245
17246 if (!dest) dest = state.pipes;
17247
17248 // got a match.
17249 state.pipes = null;
17250 state.pipesCount = 0;
17251 state.flowing = false;
17252 if (dest) dest.emit('unpipe', this, unpipeInfo);
17253 return this;
17254 }
17255
17256 // slow case. multiple pipe destinations.
17257
17258 if (!dest) {
17259 // remove all.
17260 var dests = state.pipes;
17261 var len = state.pipesCount;
17262 state.pipes = null;
17263 state.pipesCount = 0;
17264 state.flowing = false;
17265
17266 for (var i = 0; i < len; i++) {
17267 dests[i].emit('unpipe', this, unpipeInfo);
17268 }return this;
17269 }
17270
17271 // try to find the right one.
17272 var index = indexOf(state.pipes, dest);
17273 if (index === -1) return this;
17274
17275 state.pipes.splice(index, 1);
17276 state.pipesCount -= 1;
17277 if (state.pipesCount === 1) state.pipes = state.pipes[0];
17278
17279 dest.emit('unpipe', this, unpipeInfo);
17280
17281 return this;
17282};
17283
17284// set up data events if they are asked for
17285// Ensure readable listeners eventually get something
17286Readable.prototype.on = function (ev, fn) {
17287 var res = Stream.prototype.on.call(this, ev, fn);
17288
17289 if (ev === 'data') {
17290 // Start flowing on next tick if stream isn't explicitly paused
17291 if (this._readableState.flowing !== false) this.resume();
17292 } else if (ev === 'readable') {
17293 var state = this._readableState;
17294 if (!state.endEmitted && !state.readableListening) {
17295 state.readableListening = state.needReadable = true;
17296 state.emittedReadable = false;
17297 if (!state.reading) {
17298 pna.nextTick(nReadingNextTick, this);
17299 } else if (state.length) {
17300 emitReadable(this);
17301 }
17302 }
17303 }
17304
17305 return res;
17306};
17307Readable.prototype.addListener = Readable.prototype.on;
17308
17309function nReadingNextTick(self) {
17310 debug('readable nexttick read 0');
17311 self.read(0);
17312}
17313
17314// pause() and resume() are remnants of the legacy readable stream API
17315// If the user uses them, then switch into old mode.
17316Readable.prototype.resume = function () {
17317 var state = this._readableState;
17318 if (!state.flowing) {
17319 debug('resume');
17320 state.flowing = true;
17321 resume(this, state);
17322 }
17323 return this;
17324};
17325
17326function resume(stream, state) {
17327 if (!state.resumeScheduled) {
17328 state.resumeScheduled = true;
17329 pna.nextTick(resume_, stream, state);
17330 }
17331}
17332
17333function resume_(stream, state) {
17334 if (!state.reading) {
17335 debug('resume read 0');
17336 stream.read(0);
17337 }
17338
17339 state.resumeScheduled = false;
17340 state.awaitDrain = 0;
17341 stream.emit('resume');
17342 flow(stream);
17343 if (state.flowing && !state.reading) stream.read(0);
17344}
17345
17346Readable.prototype.pause = function () {
17347 debug('call pause flowing=%j', this._readableState.flowing);
17348 if (false !== this._readableState.flowing) {
17349 debug('pause');
17350 this._readableState.flowing = false;
17351 this.emit('pause');
17352 }
17353 return this;
17354};
17355
17356function flow(stream) {
17357 var state = stream._readableState;
17358 debug('flow', state.flowing);
17359 while (state.flowing && stream.read() !== null) {}
17360}
17361
17362// wrap an old-style stream as the async data source.
17363// This is *not* part of the readable stream interface.
17364// It is an ugly unfortunate mess of history.
17365Readable.prototype.wrap = function (stream) {
17366 var _this = this;
17367
17368 var state = this._readableState;
17369 var paused = false;
17370
17371 stream.on('end', function () {
17372 debug('wrapped end');
17373 if (state.decoder && !state.ended) {
17374 var chunk = state.decoder.end();
17375 if (chunk && chunk.length) _this.push(chunk);
17376 }
17377
17378 _this.push(null);
17379 });
17380
17381 stream.on('data', function (chunk) {
17382 debug('wrapped data');
17383 if (state.decoder) chunk = state.decoder.write(chunk);
17384
17385 // don't skip over falsy values in objectMode
17386 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
17387
17388 var ret = _this.push(chunk);
17389 if (!ret) {
17390 paused = true;
17391 stream.pause();
17392 }
17393 });
17394
17395 // proxy all the other methods.
17396 // important when wrapping filters and duplexes.
17397 for (var i in stream) {
17398 if (this[i] === undefined && typeof stream[i] === 'function') {
17399 this[i] = function (method) {
17400 return function () {
17401 return stream[method].apply(stream, arguments);
17402 };
17403 }(i);
17404 }
17405 }
17406
17407 // proxy certain important events.
17408 for (var n = 0; n < kProxyEvents.length; n++) {
17409 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
17410 }
17411
17412 // when we try to consume some more bytes, simply unpause the
17413 // underlying stream.
17414 this._read = function (n) {
17415 debug('wrapped _read', n);
17416 if (paused) {
17417 paused = false;
17418 stream.resume();
17419 }
17420 };
17421
17422 return this;
17423};
17424
17425Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
17426 // making it explicit this property is not enumerable
17427 // because otherwise some prototype manipulation in
17428 // userland will fail
17429 enumerable: false,
17430 get: function () {
17431 return this._readableState.highWaterMark;
17432 }
17433});
17434
17435// exposed for testing purposes only.
17436Readable._fromList = fromList;
17437
17438// Pluck off n bytes from an array of buffers.
17439// Length is the combined lengths of all the buffers in the list.
17440// This function is designed to be inlinable, so please take care when making
17441// changes to the function body.
17442function fromList(n, state) {
17443 // nothing buffered
17444 if (state.length === 0) return null;
17445
17446 var ret;
17447 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
17448 // read it all, truncate the list
17449 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
17450 state.buffer.clear();
17451 } else {
17452 // read part of list
17453 ret = fromListPartial(n, state.buffer, state.decoder);
17454 }
17455
17456 return ret;
17457}
17458
17459// Extracts only enough buffered data to satisfy the amount requested.
17460// This function is designed to be inlinable, so please take care when making
17461// changes to the function body.
17462function fromListPartial(n, list, hasStrings) {
17463 var ret;
17464 if (n < list.head.data.length) {
17465 // slice is the same for buffers and strings
17466 ret = list.head.data.slice(0, n);
17467 list.head.data = list.head.data.slice(n);
17468 } else if (n === list.head.data.length) {
17469 // first chunk is a perfect match
17470 ret = list.shift();
17471 } else {
17472 // result spans more than one buffer
17473 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
17474 }
17475 return ret;
17476}
17477
17478// Copies a specified amount of characters from the list of buffered data
17479// chunks.
17480// This function is designed to be inlinable, so please take care when making
17481// changes to the function body.
17482function copyFromBufferString(n, list) {
17483 var p = list.head;
17484 var c = 1;
17485 var ret = p.data;
17486 n -= ret.length;
17487 while (p = p.next) {
17488 var str = p.data;
17489 var nb = n > str.length ? str.length : n;
17490 if (nb === str.length) ret += str;else ret += str.slice(0, n);
17491 n -= nb;
17492 if (n === 0) {
17493 if (nb === str.length) {
17494 ++c;
17495 if (p.next) list.head = p.next;else list.head = list.tail = null;
17496 } else {
17497 list.head = p;
17498 p.data = str.slice(nb);
17499 }
17500 break;
17501 }
17502 ++c;
17503 }
17504 list.length -= c;
17505 return ret;
17506}
17507
17508// Copies a specified amount of bytes from the list of buffered data chunks.
17509// This function is designed to be inlinable, so please take care when making
17510// changes to the function body.
17511function copyFromBuffer(n, list) {
17512 var ret = Buffer.allocUnsafe(n);
17513 var p = list.head;
17514 var c = 1;
17515 p.data.copy(ret);
17516 n -= p.data.length;
17517 while (p = p.next) {
17518 var buf = p.data;
17519 var nb = n > buf.length ? buf.length : n;
17520 buf.copy(ret, ret.length - n, 0, nb);
17521 n -= nb;
17522 if (n === 0) {
17523 if (nb === buf.length) {
17524 ++c;
17525 if (p.next) list.head = p.next;else list.head = list.tail = null;
17526 } else {
17527 list.head = p;
17528 p.data = buf.slice(nb);
17529 }
17530 break;
17531 }
17532 ++c;
17533 }
17534 list.length -= c;
17535 return ret;
17536}
17537
17538function endReadable(stream) {
17539 var state = stream._readableState;
17540
17541 // If we get here before consuming all the bytes, then that is a
17542 // bug in node. Should never happen.
17543 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
17544
17545 if (!state.endEmitted) {
17546 state.ended = true;
17547 pna.nextTick(endReadableNT, state, stream);
17548 }
17549}
17550
17551function endReadableNT(state, stream) {
17552 // Check that we didn't get one last unshift.
17553 if (!state.endEmitted && state.length === 0) {
17554 state.endEmitted = true;
17555 stream.readable = false;
17556 stream.emit('end');
17557 }
17558}
17559
17560function indexOf(xs, x) {
17561 for (var i = 0, l = xs.length; i < l; i++) {
17562 if (xs[i] === x) return i;
17563 }
17564 return -1;
17565}
17566}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17567
17568},{"./_stream_duplex":129,"./internal/streams/BufferList":134,"./internal/streams/destroy":135,"./internal/streams/stream":136,"_process":125,"core-util-is":63,"events":64,"inherits":68,"isarray":70,"process-nextick-args":124,"safe-buffer":138,"string_decoder/":143,"util":7}],132:[function(require,module,exports){
17569// Copyright Joyent, Inc. and other Node contributors.
17570//
17571// Permission is hereby granted, free of charge, to any person obtaining a
17572// copy of this software and associated documentation files (the
17573// "Software"), to deal in the Software without restriction, including
17574// without limitation the rights to use, copy, modify, merge, publish,
17575// distribute, sublicense, and/or sell copies of the Software, and to permit
17576// persons to whom the Software is furnished to do so, subject to the
17577// following conditions:
17578//
17579// The above copyright notice and this permission notice shall be included
17580// in all copies or substantial portions of the Software.
17581//
17582// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17583// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17584// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17585// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17586// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17587// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17588// USE OR OTHER DEALINGS IN THE SOFTWARE.
17589
17590// a transform stream is a readable/writable stream where you do
17591// something with the data. Sometimes it's called a "filter",
17592// but that's not a great name for it, since that implies a thing where
17593// some bits pass through, and others are simply ignored. (That would
17594// be a valid example of a transform, of course.)
17595//
17596// While the output is causally related to the input, it's not a
17597// necessarily symmetric or synchronous transformation. For example,
17598// a zlib stream might take multiple plain-text writes(), and then
17599// emit a single compressed chunk some time in the future.
17600//
17601// Here's how this works:
17602//
17603// The Transform stream has all the aspects of the readable and writable
17604// stream classes. When you write(chunk), that calls _write(chunk,cb)
17605// internally, and returns false if there's a lot of pending writes
17606// buffered up. When you call read(), that calls _read(n) until
17607// there's enough pending readable data buffered up.
17608//
17609// In a transform stream, the written data is placed in a buffer. When
17610// _read(n) is called, it transforms the queued up data, calling the
17611// buffered _write cb's as it consumes chunks. If consuming a single
17612// written chunk would result in multiple output chunks, then the first
17613// outputted bit calls the readcb, and subsequent chunks just go into
17614// the read buffer, and will cause it to emit 'readable' if necessary.
17615//
17616// This way, back-pressure is actually determined by the reading side,
17617// since _read has to be called to start processing a new chunk. However,
17618// a pathological inflate type of transform can cause excessive buffering
17619// here. For example, imagine a stream where every byte of input is
17620// interpreted as an integer from 0-255, and then results in that many
17621// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
17622// 1kb of data being output. In this case, you could write a very small
17623// amount of input, and end up with a very large amount of output. In
17624// such a pathological inflating mechanism, there'd be no way to tell
17625// the system to stop doing the transform. A single 4MB write could
17626// cause the system to run out of memory.
17627//
17628// However, even in such a pathological case, only a single written chunk
17629// would be consumed, and then the rest would wait (un-transformed) until
17630// the results of the previous transformed chunk were consumed.
17631
17632'use strict';
17633
17634module.exports = Transform;
17635
17636var Duplex = require('./_stream_duplex');
17637
17638/*<replacement>*/
17639var util = require('core-util-is');
17640util.inherits = require('inherits');
17641/*</replacement>*/
17642
17643util.inherits(Transform, Duplex);
17644
17645function afterTransform(er, data) {
17646 var ts = this._transformState;
17647 ts.transforming = false;
17648
17649 var cb = ts.writecb;
17650
17651 if (!cb) {
17652 return this.emit('error', new Error('write callback called multiple times'));
17653 }
17654
17655 ts.writechunk = null;
17656 ts.writecb = null;
17657
17658 if (data != null) // single equals check for both `null` and `undefined`
17659 this.push(data);
17660
17661 cb(er);
17662
17663 var rs = this._readableState;
17664 rs.reading = false;
17665 if (rs.needReadable || rs.length < rs.highWaterMark) {
17666 this._read(rs.highWaterMark);
17667 }
17668}
17669
17670function Transform(options) {
17671 if (!(this instanceof Transform)) return new Transform(options);
17672
17673 Duplex.call(this, options);
17674
17675 this._transformState = {
17676 afterTransform: afterTransform.bind(this),
17677 needTransform: false,
17678 transforming: false,
17679 writecb: null,
17680 writechunk: null,
17681 writeencoding: null
17682 };
17683
17684 // start out asking for a readable event once data is transformed.
17685 this._readableState.needReadable = true;
17686
17687 // we have implemented the _read method, and done the other things
17688 // that Readable wants before the first _read call, so unset the
17689 // sync guard flag.
17690 this._readableState.sync = false;
17691
17692 if (options) {
17693 if (typeof options.transform === 'function') this._transform = options.transform;
17694
17695 if (typeof options.flush === 'function') this._flush = options.flush;
17696 }
17697
17698 // When the writable side finishes, then flush out anything remaining.
17699 this.on('prefinish', prefinish);
17700}
17701
17702function prefinish() {
17703 var _this = this;
17704
17705 if (typeof this._flush === 'function') {
17706 this._flush(function (er, data) {
17707 done(_this, er, data);
17708 });
17709 } else {
17710 done(this, null, null);
17711 }
17712}
17713
17714Transform.prototype.push = function (chunk, encoding) {
17715 this._transformState.needTransform = false;
17716 return Duplex.prototype.push.call(this, chunk, encoding);
17717};
17718
17719// This is the part where you do stuff!
17720// override this function in implementation classes.
17721// 'chunk' is an input chunk.
17722//
17723// Call `push(newChunk)` to pass along transformed output
17724// to the readable side. You may call 'push' zero or more times.
17725//
17726// Call `cb(err)` when you are done with this chunk. If you pass
17727// an error, then that'll put the hurt on the whole operation. If you
17728// never call cb(), then you'll never get another chunk.
17729Transform.prototype._transform = function (chunk, encoding, cb) {
17730 throw new Error('_transform() is not implemented');
17731};
17732
17733Transform.prototype._write = function (chunk, encoding, cb) {
17734 var ts = this._transformState;
17735 ts.writecb = cb;
17736 ts.writechunk = chunk;
17737 ts.writeencoding = encoding;
17738 if (!ts.transforming) {
17739 var rs = this._readableState;
17740 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
17741 }
17742};
17743
17744// Doesn't matter what the args are here.
17745// _transform does all the work.
17746// That we got here means that the readable side wants more data.
17747Transform.prototype._read = function (n) {
17748 var ts = this._transformState;
17749
17750 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
17751 ts.transforming = true;
17752 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
17753 } else {
17754 // mark that we need a transform, so that any data that comes in
17755 // will get processed, now that we've asked for it.
17756 ts.needTransform = true;
17757 }
17758};
17759
17760Transform.prototype._destroy = function (err, cb) {
17761 var _this2 = this;
17762
17763 Duplex.prototype._destroy.call(this, err, function (err2) {
17764 cb(err2);
17765 _this2.emit('close');
17766 });
17767};
17768
17769function done(stream, er, data) {
17770 if (er) return stream.emit('error', er);
17771
17772 if (data != null) // single equals check for both `null` and `undefined`
17773 stream.push(data);
17774
17775 // if there's nothing in the write buffer, then that means
17776 // that nothing more will ever be provided
17777 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
17778
17779 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
17780
17781 return stream.push(null);
17782}
17783},{"./_stream_duplex":129,"core-util-is":63,"inherits":68}],133:[function(require,module,exports){
17784(function (process,global,setImmediate){
17785// Copyright Joyent, Inc. and other Node contributors.
17786//
17787// Permission is hereby granted, free of charge, to any person obtaining a
17788// copy of this software and associated documentation files (the
17789// "Software"), to deal in the Software without restriction, including
17790// without limitation the rights to use, copy, modify, merge, publish,
17791// distribute, sublicense, and/or sell copies of the Software, and to permit
17792// persons to whom the Software is furnished to do so, subject to the
17793// following conditions:
17794//
17795// The above copyright notice and this permission notice shall be included
17796// in all copies or substantial portions of the Software.
17797//
17798// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17799// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17800// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17801// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17802// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17803// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17804// USE OR OTHER DEALINGS IN THE SOFTWARE.
17805
17806// A bit simpler than readable streams.
17807// Implement an async ._write(chunk, encoding, cb), and it'll handle all
17808// the drain event emission and buffering.
17809
17810'use strict';
17811
17812/*<replacement>*/
17813
17814var pna = require('process-nextick-args');
17815/*</replacement>*/
17816
17817module.exports = Writable;
17818
17819/* <replacement> */
17820function WriteReq(chunk, encoding, cb) {
17821 this.chunk = chunk;
17822 this.encoding = encoding;
17823 this.callback = cb;
17824 this.next = null;
17825}
17826
17827// It seems a linked list but it is not
17828// there will be only 2 of these for each stream
17829function CorkedRequest(state) {
17830 var _this = this;
17831
17832 this.next = null;
17833 this.entry = null;
17834 this.finish = function () {
17835 onCorkedFinish(_this, state);
17836 };
17837}
17838/* </replacement> */
17839
17840/*<replacement>*/
17841var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
17842/*</replacement>*/
17843
17844/*<replacement>*/
17845var Duplex;
17846/*</replacement>*/
17847
17848Writable.WritableState = WritableState;
17849
17850/*<replacement>*/
17851var util = require('core-util-is');
17852util.inherits = require('inherits');
17853/*</replacement>*/
17854
17855/*<replacement>*/
17856var internalUtil = {
17857 deprecate: require('util-deprecate')
17858};
17859/*</replacement>*/
17860
17861/*<replacement>*/
17862var Stream = require('./internal/streams/stream');
17863/*</replacement>*/
17864
17865/*<replacement>*/
17866
17867var Buffer = require('safe-buffer').Buffer;
17868var OurUint8Array = global.Uint8Array || function () {};
17869function _uint8ArrayToBuffer(chunk) {
17870 return Buffer.from(chunk);
17871}
17872function _isUint8Array(obj) {
17873 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
17874}
17875
17876/*</replacement>*/
17877
17878var destroyImpl = require('./internal/streams/destroy');
17879
17880util.inherits(Writable, Stream);
17881
17882function nop() {}
17883
17884function WritableState(options, stream) {
17885 Duplex = Duplex || require('./_stream_duplex');
17886
17887 options = options || {};
17888
17889 // Duplex streams are both readable and writable, but share
17890 // the same options object.
17891 // However, some cases require setting options to different
17892 // values for the readable and the writable sides of the duplex stream.
17893 // These options can be provided separately as readableXXX and writableXXX.
17894 var isDuplex = stream instanceof Duplex;
17895
17896 // object stream flag to indicate whether or not this stream
17897 // contains buffers or objects.
17898 this.objectMode = !!options.objectMode;
17899
17900 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
17901
17902 // the point at which write() starts returning false
17903 // Note: 0 is a valid value, means that we always return false if
17904 // the entire buffer is not flushed immediately on write()
17905 var hwm = options.highWaterMark;
17906 var writableHwm = options.writableHighWaterMark;
17907 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
17908
17909 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
17910
17911 // cast to ints.
17912 this.highWaterMark = Math.floor(this.highWaterMark);
17913
17914 // if _final has been called
17915 this.finalCalled = false;
17916
17917 // drain event flag.
17918 this.needDrain = false;
17919 // at the start of calling end()
17920 this.ending = false;
17921 // when end() has been called, and returned
17922 this.ended = false;
17923 // when 'finish' is emitted
17924 this.finished = false;
17925
17926 // has it been destroyed
17927 this.destroyed = false;
17928
17929 // should we decode strings into buffers before passing to _write?
17930 // this is here so that some node-core streams can optimize string
17931 // handling at a lower level.
17932 var noDecode = options.decodeStrings === false;
17933 this.decodeStrings = !noDecode;
17934
17935 // Crypto is kind of old and crusty. Historically, its default string
17936 // encoding is 'binary' so we have to make this configurable.
17937 // Everything else in the universe uses 'utf8', though.
17938 this.defaultEncoding = options.defaultEncoding || 'utf8';
17939
17940 // not an actual buffer we keep track of, but a measurement
17941 // of how much we're waiting to get pushed to some underlying
17942 // socket or file.
17943 this.length = 0;
17944
17945 // a flag to see when we're in the middle of a write.
17946 this.writing = false;
17947
17948 // when true all writes will be buffered until .uncork() call
17949 this.corked = 0;
17950
17951 // a flag to be able to tell if the onwrite cb is called immediately,
17952 // or on a later tick. We set this to true at first, because any
17953 // actions that shouldn't happen until "later" should generally also
17954 // not happen before the first write call.
17955 this.sync = true;
17956
17957 // a flag to know if we're processing previously buffered items, which
17958 // may call the _write() callback in the same tick, so that we don't
17959 // end up in an overlapped onwrite situation.
17960 this.bufferProcessing = false;
17961
17962 // the callback that's passed to _write(chunk,cb)
17963 this.onwrite = function (er) {
17964 onwrite(stream, er);
17965 };
17966
17967 // the callback that the user supplies to write(chunk,encoding,cb)
17968 this.writecb = null;
17969
17970 // the amount that is being written when _write is called.
17971 this.writelen = 0;
17972
17973 this.bufferedRequest = null;
17974 this.lastBufferedRequest = null;
17975
17976 // number of pending user-supplied write callbacks
17977 // this must be 0 before 'finish' can be emitted
17978 this.pendingcb = 0;
17979
17980 // emit prefinish if the only thing we're waiting for is _write cbs
17981 // This is relevant for synchronous Transform streams
17982 this.prefinished = false;
17983
17984 // True if the error was already emitted and should not be thrown again
17985 this.errorEmitted = false;
17986
17987 // count buffered requests
17988 this.bufferedRequestCount = 0;
17989
17990 // allocate the first CorkedRequest, there is always
17991 // one allocated and free to use, and we maintain at most two
17992 this.corkedRequestsFree = new CorkedRequest(this);
17993}
17994
17995WritableState.prototype.getBuffer = function getBuffer() {
17996 var current = this.bufferedRequest;
17997 var out = [];
17998 while (current) {
17999 out.push(current);
18000 current = current.next;
18001 }
18002 return out;
18003};
18004
18005(function () {
18006 try {
18007 Object.defineProperty(WritableState.prototype, 'buffer', {
18008 get: internalUtil.deprecate(function () {
18009 return this.getBuffer();
18010 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
18011 });
18012 } catch (_) {}
18013})();
18014
18015// Test _writableState for inheritance to account for Duplex streams,
18016// whose prototype chain only points to Readable.
18017var realHasInstance;
18018if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
18019 realHasInstance = Function.prototype[Symbol.hasInstance];
18020 Object.defineProperty(Writable, Symbol.hasInstance, {
18021 value: function (object) {
18022 if (realHasInstance.call(this, object)) return true;
18023 if (this !== Writable) return false;
18024
18025 return object && object._writableState instanceof WritableState;
18026 }
18027 });
18028} else {
18029 realHasInstance = function (object) {
18030 return object instanceof this;
18031 };
18032}
18033
18034function Writable(options) {
18035 Duplex = Duplex || require('./_stream_duplex');
18036
18037 // Writable ctor is applied to Duplexes, too.
18038 // `realHasInstance` is necessary because using plain `instanceof`
18039 // would return false, as no `_writableState` property is attached.
18040
18041 // Trying to use the custom `instanceof` for Writable here will also break the
18042 // Node.js LazyTransform implementation, which has a non-trivial getter for
18043 // `_writableState` that would lead to infinite recursion.
18044 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
18045 return new Writable(options);
18046 }
18047
18048 this._writableState = new WritableState(options, this);
18049
18050 // legacy.
18051 this.writable = true;
18052
18053 if (options) {
18054 if (typeof options.write === 'function') this._write = options.write;
18055
18056 if (typeof options.writev === 'function') this._writev = options.writev;
18057
18058 if (typeof options.destroy === 'function') this._destroy = options.destroy;
18059
18060 if (typeof options.final === 'function') this._final = options.final;
18061 }
18062
18063 Stream.call(this);
18064}
18065
18066// Otherwise people can pipe Writable streams, which is just wrong.
18067Writable.prototype.pipe = function () {
18068 this.emit('error', new Error('Cannot pipe, not readable'));
18069};
18070
18071function writeAfterEnd(stream, cb) {
18072 var er = new Error('write after end');
18073 // TODO: defer error events consistently everywhere, not just the cb
18074 stream.emit('error', er);
18075 pna.nextTick(cb, er);
18076}
18077
18078// Checks that a user-supplied chunk is valid, especially for the particular
18079// mode the stream is in. Currently this means that `null` is never accepted
18080// and undefined/non-string values are only allowed in object mode.
18081function validChunk(stream, state, chunk, cb) {
18082 var valid = true;
18083 var er = false;
18084
18085 if (chunk === null) {
18086 er = new TypeError('May not write null values to stream');
18087 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
18088 er = new TypeError('Invalid non-string/buffer chunk');
18089 }
18090 if (er) {
18091 stream.emit('error', er);
18092 pna.nextTick(cb, er);
18093 valid = false;
18094 }
18095 return valid;
18096}
18097
18098Writable.prototype.write = function (chunk, encoding, cb) {
18099 var state = this._writableState;
18100 var ret = false;
18101 var isBuf = !state.objectMode && _isUint8Array(chunk);
18102
18103 if (isBuf && !Buffer.isBuffer(chunk)) {
18104 chunk = _uint8ArrayToBuffer(chunk);
18105 }
18106
18107 if (typeof encoding === 'function') {
18108 cb = encoding;
18109 encoding = null;
18110 }
18111
18112 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
18113
18114 if (typeof cb !== 'function') cb = nop;
18115
18116 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
18117 state.pendingcb++;
18118 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
18119 }
18120
18121 return ret;
18122};
18123
18124Writable.prototype.cork = function () {
18125 var state = this._writableState;
18126
18127 state.corked++;
18128};
18129
18130Writable.prototype.uncork = function () {
18131 var state = this._writableState;
18132
18133 if (state.corked) {
18134 state.corked--;
18135
18136 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
18137 }
18138};
18139
18140Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
18141 // node::ParseEncoding() requires lower case.
18142 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
18143 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
18144 this._writableState.defaultEncoding = encoding;
18145 return this;
18146};
18147
18148function decodeChunk(state, chunk, encoding) {
18149 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
18150 chunk = Buffer.from(chunk, encoding);
18151 }
18152 return chunk;
18153}
18154
18155Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
18156 // making it explicit this property is not enumerable
18157 // because otherwise some prototype manipulation in
18158 // userland will fail
18159 enumerable: false,
18160 get: function () {
18161 return this._writableState.highWaterMark;
18162 }
18163});
18164
18165// if we're already writing something, then just put this
18166// in the queue, and wait our turn. Otherwise, call _write
18167// If we return false, then we need a drain event, so set that flag.
18168function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
18169 if (!isBuf) {
18170 var newChunk = decodeChunk(state, chunk, encoding);
18171 if (chunk !== newChunk) {
18172 isBuf = true;
18173 encoding = 'buffer';
18174 chunk = newChunk;
18175 }
18176 }
18177 var len = state.objectMode ? 1 : chunk.length;
18178
18179 state.length += len;
18180
18181 var ret = state.length < state.highWaterMark;
18182 // we must ensure that previous needDrain will not be reset to false.
18183 if (!ret) state.needDrain = true;
18184
18185 if (state.writing || state.corked) {
18186 var last = state.lastBufferedRequest;
18187 state.lastBufferedRequest = {
18188 chunk: chunk,
18189 encoding: encoding,
18190 isBuf: isBuf,
18191 callback: cb,
18192 next: null
18193 };
18194 if (last) {
18195 last.next = state.lastBufferedRequest;
18196 } else {
18197 state.bufferedRequest = state.lastBufferedRequest;
18198 }
18199 state.bufferedRequestCount += 1;
18200 } else {
18201 doWrite(stream, state, false, len, chunk, encoding, cb);
18202 }
18203
18204 return ret;
18205}
18206
18207function doWrite(stream, state, writev, len, chunk, encoding, cb) {
18208 state.writelen = len;
18209 state.writecb = cb;
18210 state.writing = true;
18211 state.sync = true;
18212 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
18213 state.sync = false;
18214}
18215
18216function onwriteError(stream, state, sync, er, cb) {
18217 --state.pendingcb;
18218
18219 if (sync) {
18220 // defer the callback if we are being called synchronously
18221 // to avoid piling up things on the stack
18222 pna.nextTick(cb, er);
18223 // this can emit finish, and it will always happen
18224 // after error
18225 pna.nextTick(finishMaybe, stream, state);
18226 stream._writableState.errorEmitted = true;
18227 stream.emit('error', er);
18228 } else {
18229 // the caller expect this to happen before if
18230 // it is async
18231 cb(er);
18232 stream._writableState.errorEmitted = true;
18233 stream.emit('error', er);
18234 // this can emit finish, but finish must
18235 // always follow error
18236 finishMaybe(stream, state);
18237 }
18238}
18239
18240function onwriteStateUpdate(state) {
18241 state.writing = false;
18242 state.writecb = null;
18243 state.length -= state.writelen;
18244 state.writelen = 0;
18245}
18246
18247function onwrite(stream, er) {
18248 var state = stream._writableState;
18249 var sync = state.sync;
18250 var cb = state.writecb;
18251
18252 onwriteStateUpdate(state);
18253
18254 if (er) onwriteError(stream, state, sync, er, cb);else {
18255 // Check if we're actually ready to finish, but don't emit yet
18256 var finished = needFinish(state);
18257
18258 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
18259 clearBuffer(stream, state);
18260 }
18261
18262 if (sync) {
18263 /*<replacement>*/
18264 asyncWrite(afterWrite, stream, state, finished, cb);
18265 /*</replacement>*/
18266 } else {
18267 afterWrite(stream, state, finished, cb);
18268 }
18269 }
18270}
18271
18272function afterWrite(stream, state, finished, cb) {
18273 if (!finished) onwriteDrain(stream, state);
18274 state.pendingcb--;
18275 cb();
18276 finishMaybe(stream, state);
18277}
18278
18279// Must force callback to be called on nextTick, so that we don't
18280// emit 'drain' before the write() consumer gets the 'false' return
18281// value, and has a chance to attach a 'drain' listener.
18282function onwriteDrain(stream, state) {
18283 if (state.length === 0 && state.needDrain) {
18284 state.needDrain = false;
18285 stream.emit('drain');
18286 }
18287}
18288
18289// if there's something in the buffer waiting, then process it
18290function clearBuffer(stream, state) {
18291 state.bufferProcessing = true;
18292 var entry = state.bufferedRequest;
18293
18294 if (stream._writev && entry && entry.next) {
18295 // Fast case, write everything using _writev()
18296 var l = state.bufferedRequestCount;
18297 var buffer = new Array(l);
18298 var holder = state.corkedRequestsFree;
18299 holder.entry = entry;
18300
18301 var count = 0;
18302 var allBuffers = true;
18303 while (entry) {
18304 buffer[count] = entry;
18305 if (!entry.isBuf) allBuffers = false;
18306 entry = entry.next;
18307 count += 1;
18308 }
18309 buffer.allBuffers = allBuffers;
18310
18311 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
18312
18313 // doWrite is almost always async, defer these to save a bit of time
18314 // as the hot path ends with doWrite
18315 state.pendingcb++;
18316 state.lastBufferedRequest = null;
18317 if (holder.next) {
18318 state.corkedRequestsFree = holder.next;
18319 holder.next = null;
18320 } else {
18321 state.corkedRequestsFree = new CorkedRequest(state);
18322 }
18323 state.bufferedRequestCount = 0;
18324 } else {
18325 // Slow case, write chunks one-by-one
18326 while (entry) {
18327 var chunk = entry.chunk;
18328 var encoding = entry.encoding;
18329 var cb = entry.callback;
18330 var len = state.objectMode ? 1 : chunk.length;
18331
18332 doWrite(stream, state, false, len, chunk, encoding, cb);
18333 entry = entry.next;
18334 state.bufferedRequestCount--;
18335 // if we didn't call the onwrite immediately, then
18336 // it means that we need to wait until it does.
18337 // also, that means that the chunk and cb are currently
18338 // being processed, so move the buffer counter past them.
18339 if (state.writing) {
18340 break;
18341 }
18342 }
18343
18344 if (entry === null) state.lastBufferedRequest = null;
18345 }
18346
18347 state.bufferedRequest = entry;
18348 state.bufferProcessing = false;
18349}
18350
18351Writable.prototype._write = function (chunk, encoding, cb) {
18352 cb(new Error('_write() is not implemented'));
18353};
18354
18355Writable.prototype._writev = null;
18356
18357Writable.prototype.end = function (chunk, encoding, cb) {
18358 var state = this._writableState;
18359
18360 if (typeof chunk === 'function') {
18361 cb = chunk;
18362 chunk = null;
18363 encoding = null;
18364 } else if (typeof encoding === 'function') {
18365 cb = encoding;
18366 encoding = null;
18367 }
18368
18369 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
18370
18371 // .end() fully uncorks
18372 if (state.corked) {
18373 state.corked = 1;
18374 this.uncork();
18375 }
18376
18377 // ignore unnecessary end() calls.
18378 if (!state.ending && !state.finished) endWritable(this, state, cb);
18379};
18380
18381function needFinish(state) {
18382 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
18383}
18384function callFinal(stream, state) {
18385 stream._final(function (err) {
18386 state.pendingcb--;
18387 if (err) {
18388 stream.emit('error', err);
18389 }
18390 state.prefinished = true;
18391 stream.emit('prefinish');
18392 finishMaybe(stream, state);
18393 });
18394}
18395function prefinish(stream, state) {
18396 if (!state.prefinished && !state.finalCalled) {
18397 if (typeof stream._final === 'function') {
18398 state.pendingcb++;
18399 state.finalCalled = true;
18400 pna.nextTick(callFinal, stream, state);
18401 } else {
18402 state.prefinished = true;
18403 stream.emit('prefinish');
18404 }
18405 }
18406}
18407
18408function finishMaybe(stream, state) {
18409 var need = needFinish(state);
18410 if (need) {
18411 prefinish(stream, state);
18412 if (state.pendingcb === 0) {
18413 state.finished = true;
18414 stream.emit('finish');
18415 }
18416 }
18417 return need;
18418}
18419
18420function endWritable(stream, state, cb) {
18421 state.ending = true;
18422 finishMaybe(stream, state);
18423 if (cb) {
18424 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
18425 }
18426 state.ended = true;
18427 stream.writable = false;
18428}
18429
18430function onCorkedFinish(corkReq, state, err) {
18431 var entry = corkReq.entry;
18432 corkReq.entry = null;
18433 while (entry) {
18434 var cb = entry.callback;
18435 state.pendingcb--;
18436 cb(err);
18437 entry = entry.next;
18438 }
18439 if (state.corkedRequestsFree) {
18440 state.corkedRequestsFree.next = corkReq;
18441 } else {
18442 state.corkedRequestsFree = corkReq;
18443 }
18444}
18445
18446Object.defineProperty(Writable.prototype, 'destroyed', {
18447 get: function () {
18448 if (this._writableState === undefined) {
18449 return false;
18450 }
18451 return this._writableState.destroyed;
18452 },
18453 set: function (value) {
18454 // we ignore the value if the stream
18455 // has not been initialized yet
18456 if (!this._writableState) {
18457 return;
18458 }
18459
18460 // backward compatibility, the user is explicitly
18461 // managing destroyed
18462 this._writableState.destroyed = value;
18463 }
18464});
18465
18466Writable.prototype.destroy = destroyImpl.destroy;
18467Writable.prototype._undestroy = destroyImpl.undestroy;
18468Writable.prototype._destroy = function (err, cb) {
18469 this.end();
18470 cb(err);
18471};
18472}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
18473
18474},{"./_stream_duplex":129,"./internal/streams/destroy":135,"./internal/streams/stream":136,"_process":125,"core-util-is":63,"inherits":68,"process-nextick-args":124,"safe-buffer":138,"timers":146,"util-deprecate":150}],134:[function(require,module,exports){
18475'use strict';
18476
18477function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18478
18479var Buffer = require('safe-buffer').Buffer;
18480var util = require('util');
18481
18482function copyBuffer(src, target, offset) {
18483 src.copy(target, offset);
18484}
18485
18486module.exports = function () {
18487 function BufferList() {
18488 _classCallCheck(this, BufferList);
18489
18490 this.head = null;
18491 this.tail = null;
18492 this.length = 0;
18493 }
18494
18495 BufferList.prototype.push = function push(v) {
18496 var entry = { data: v, next: null };
18497 if (this.length > 0) this.tail.next = entry;else this.head = entry;
18498 this.tail = entry;
18499 ++this.length;
18500 };
18501
18502 BufferList.prototype.unshift = function unshift(v) {
18503 var entry = { data: v, next: this.head };
18504 if (this.length === 0) this.tail = entry;
18505 this.head = entry;
18506 ++this.length;
18507 };
18508
18509 BufferList.prototype.shift = function shift() {
18510 if (this.length === 0) return;
18511 var ret = this.head.data;
18512 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
18513 --this.length;
18514 return ret;
18515 };
18516
18517 BufferList.prototype.clear = function clear() {
18518 this.head = this.tail = null;
18519 this.length = 0;
18520 };
18521
18522 BufferList.prototype.join = function join(s) {
18523 if (this.length === 0) return '';
18524 var p = this.head;
18525 var ret = '' + p.data;
18526 while (p = p.next) {
18527 ret += s + p.data;
18528 }return ret;
18529 };
18530
18531 BufferList.prototype.concat = function concat(n) {
18532 if (this.length === 0) return Buffer.alloc(0);
18533 if (this.length === 1) return this.head.data;
18534 var ret = Buffer.allocUnsafe(n >>> 0);
18535 var p = this.head;
18536 var i = 0;
18537 while (p) {
18538 copyBuffer(p.data, ret, i);
18539 i += p.data.length;
18540 p = p.next;
18541 }
18542 return ret;
18543 };
18544
18545 return BufferList;
18546}();
18547
18548if (util && util.inspect && util.inspect.custom) {
18549 module.exports.prototype[util.inspect.custom] = function () {
18550 var obj = util.inspect({ length: this.length });
18551 return this.constructor.name + ' ' + obj;
18552 };
18553}
18554},{"safe-buffer":138,"util":7}],135:[function(require,module,exports){
18555'use strict';
18556
18557/*<replacement>*/
18558
18559var pna = require('process-nextick-args');
18560/*</replacement>*/
18561
18562// undocumented cb() API, needed for core, not for public API
18563function destroy(err, cb) {
18564 var _this = this;
18565
18566 var readableDestroyed = this._readableState && this._readableState.destroyed;
18567 var writableDestroyed = this._writableState && this._writableState.destroyed;
18568
18569 if (readableDestroyed || writableDestroyed) {
18570 if (cb) {
18571 cb(err);
18572 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
18573 pna.nextTick(emitErrorNT, this, err);
18574 }
18575 return this;
18576 }
18577
18578 // we set destroyed to true before firing error callbacks in order
18579 // to make it re-entrance safe in case destroy() is called within callbacks
18580
18581 if (this._readableState) {
18582 this._readableState.destroyed = true;
18583 }
18584
18585 // if this is a duplex stream mark the writable part as destroyed as well
18586 if (this._writableState) {
18587 this._writableState.destroyed = true;
18588 }
18589
18590 this._destroy(err || null, function (err) {
18591 if (!cb && err) {
18592 pna.nextTick(emitErrorNT, _this, err);
18593 if (_this._writableState) {
18594 _this._writableState.errorEmitted = true;
18595 }
18596 } else if (cb) {
18597 cb(err);
18598 }
18599 });
18600
18601 return this;
18602}
18603
18604function undestroy() {
18605 if (this._readableState) {
18606 this._readableState.destroyed = false;
18607 this._readableState.reading = false;
18608 this._readableState.ended = false;
18609 this._readableState.endEmitted = false;
18610 }
18611
18612 if (this._writableState) {
18613 this._writableState.destroyed = false;
18614 this._writableState.ended = false;
18615 this._writableState.ending = false;
18616 this._writableState.finished = false;
18617 this._writableState.errorEmitted = false;
18618 }
18619}
18620
18621function emitErrorNT(self, err) {
18622 self.emit('error', err);
18623}
18624
18625module.exports = {
18626 destroy: destroy,
18627 undestroy: undestroy
18628};
18629},{"process-nextick-args":124}],136:[function(require,module,exports){
18630module.exports = require('events').EventEmitter;
18631
18632},{"events":64}],137:[function(require,module,exports){
18633exports = module.exports = require('./lib/_stream_readable.js');
18634exports.Stream = exports;
18635exports.Readable = exports;
18636exports.Writable = require('./lib/_stream_writable.js');
18637exports.Duplex = require('./lib/_stream_duplex.js');
18638exports.Transform = require('./lib/_stream_transform.js');
18639exports.PassThrough = require('./lib/_stream_passthrough.js');
18640
18641},{"./lib/_stream_duplex.js":129,"./lib/_stream_passthrough.js":130,"./lib/_stream_readable.js":131,"./lib/_stream_transform.js":132,"./lib/_stream_writable.js":133}],138:[function(require,module,exports){
18642/* eslint-disable node/no-deprecated-api */
18643var buffer = require('buffer')
18644var Buffer = buffer.Buffer
18645
18646// alternative to using Object.keys for old browsers
18647function copyProps (src, dst) {
18648 for (var key in src) {
18649 dst[key] = src[key]
18650 }
18651}
18652if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
18653 module.exports = buffer
18654} else {
18655 // Copy properties from require('buffer')
18656 copyProps(buffer, exports)
18657 exports.Buffer = SafeBuffer
18658}
18659
18660function SafeBuffer (arg, encodingOrOffset, length) {
18661 return Buffer(arg, encodingOrOffset, length)
18662}
18663
18664// Copy static methods from Buffer
18665copyProps(Buffer, SafeBuffer)
18666
18667SafeBuffer.from = function (arg, encodingOrOffset, length) {
18668 if (typeof arg === 'number') {
18669 throw new TypeError('Argument must not be a number')
18670 }
18671 return Buffer(arg, encodingOrOffset, length)
18672}
18673
18674SafeBuffer.alloc = function (size, fill, encoding) {
18675 if (typeof size !== 'number') {
18676 throw new TypeError('Argument must be a number')
18677 }
18678 var buf = Buffer(size)
18679 if (fill !== undefined) {
18680 if (typeof encoding === 'string') {
18681 buf.fill(fill, encoding)
18682 } else {
18683 buf.fill(fill)
18684 }
18685 } else {
18686 buf.fill(0)
18687 }
18688 return buf
18689}
18690
18691SafeBuffer.allocUnsafe = function (size) {
18692 if (typeof size !== 'number') {
18693 throw new TypeError('Argument must be a number')
18694 }
18695 return Buffer(size)
18696}
18697
18698SafeBuffer.allocUnsafeSlow = function (size) {
18699 if (typeof size !== 'number') {
18700 throw new TypeError('Argument must be a number')
18701 }
18702 return buffer.SlowBuffer(size)
18703}
18704
18705},{"buffer":9}],139:[function(require,module,exports){
18706(function (global){
18707var ClientRequest = require('./lib/request')
18708var response = require('./lib/response')
18709var extend = require('xtend')
18710var statusCodes = require('builtin-status-codes')
18711var url = require('url')
18712
18713var http = exports
18714
18715http.request = function (opts, cb) {
18716 if (typeof opts === 'string')
18717 opts = url.parse(opts)
18718 else
18719 opts = extend(opts)
18720
18721 // Normally, the page is loaded from http or https, so not specifying a protocol
18722 // will result in a (valid) protocol-relative url. However, this won't work if
18723 // the protocol is something else, like 'file:'
18724 var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
18725
18726 var protocol = opts.protocol || defaultProtocol
18727 var host = opts.hostname || opts.host
18728 var port = opts.port
18729 var path = opts.path || '/'
18730
18731 // Necessary for IPv6 addresses
18732 if (host && host.indexOf(':') !== -1)
18733 host = '[' + host + ']'
18734
18735 // This may be a relative url. The browser should always be able to interpret it correctly.
18736 opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
18737 opts.method = (opts.method || 'GET').toUpperCase()
18738 opts.headers = opts.headers || {}
18739
18740 // Also valid opts.auth, opts.mode
18741
18742 var req = new ClientRequest(opts)
18743 if (cb)
18744 req.on('response', cb)
18745 return req
18746}
18747
18748http.get = function get (opts, cb) {
18749 var req = http.request(opts, cb)
18750 req.end()
18751 return req
18752}
18753
18754http.ClientRequest = ClientRequest
18755http.IncomingMessage = response.IncomingMessage
18756
18757http.Agent = function () {}
18758http.Agent.defaultMaxSockets = 4
18759
18760http.globalAgent = new http.Agent()
18761
18762http.STATUS_CODES = statusCodes
18763
18764http.METHODS = [
18765 'CHECKOUT',
18766 'CONNECT',
18767 'COPY',
18768 'DELETE',
18769 'GET',
18770 'HEAD',
18771 'LOCK',
18772 'M-SEARCH',
18773 'MERGE',
18774 'MKACTIVITY',
18775 'MKCOL',
18776 'MOVE',
18777 'NOTIFY',
18778 'OPTIONS',
18779 'PATCH',
18780 'POST',
18781 'PROPFIND',
18782 'PROPPATCH',
18783 'PURGE',
18784 'PUT',
18785 'REPORT',
18786 'SEARCH',
18787 'SUBSCRIBE',
18788 'TRACE',
18789 'UNLOCK',
18790 'UNSUBSCRIBE'
18791]
18792}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
18793
18794},{"./lib/request":141,"./lib/response":142,"builtin-status-codes":10,"url":148,"xtend":231}],140:[function(require,module,exports){
18795(function (global){
18796exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
18797
18798exports.writableStream = isFunction(global.WritableStream)
18799
18800exports.abortController = isFunction(global.AbortController)
18801
18802exports.blobConstructor = false
18803try {
18804 new Blob([new ArrayBuffer(1)])
18805 exports.blobConstructor = true
18806} catch (e) {}
18807
18808// The xhr request to example.com may violate some restrictive CSP configurations,
18809// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
18810// and assume support for certain features below.
18811var xhr
18812function getXHR () {
18813 // Cache the xhr value
18814 if (xhr !== undefined) return xhr
18815
18816 if (global.XMLHttpRequest) {
18817 xhr = new global.XMLHttpRequest()
18818 // If XDomainRequest is available (ie only, where xhr might not work
18819 // cross domain), use the page location. Otherwise use example.com
18820 // Note: this doesn't actually make an http request.
18821 try {
18822 xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
18823 } catch(e) {
18824 xhr = null
18825 }
18826 } else {
18827 // Service workers don't have XHR
18828 xhr = null
18829 }
18830 return xhr
18831}
18832
18833function checkTypeSupport (type) {
18834 var xhr = getXHR()
18835 if (!xhr) return false
18836 try {
18837 xhr.responseType = type
18838 return xhr.responseType === type
18839 } catch (e) {}
18840 return false
18841}
18842
18843// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
18844// Safari 7.1 appears to have fixed this bug.
18845var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
18846var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
18847
18848// If fetch is supported, then arraybuffer will be supported too. Skip calling
18849// checkTypeSupport(), since that calls getXHR().
18850exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'))
18851
18852// These next two tests unavoidably show warnings in Chrome. Since fetch will always
18853// be used if it's available, just return false for these to avoid the warnings.
18854exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
18855exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
18856 checkTypeSupport('moz-chunked-arraybuffer')
18857
18858// If fetch is supported, then overrideMimeType will be supported too. Skip calling
18859// getXHR().
18860exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
18861
18862exports.vbArray = isFunction(global.VBArray)
18863
18864function isFunction (value) {
18865 return typeof value === 'function'
18866}
18867
18868xhr = null // Help gc
18869
18870}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
18871
18872},{}],141:[function(require,module,exports){
18873(function (process,global,Buffer){
18874var capability = require('./capability')
18875var inherits = require('inherits')
18876var response = require('./response')
18877var stream = require('readable-stream')
18878var toArrayBuffer = require('to-arraybuffer')
18879
18880var IncomingMessage = response.IncomingMessage
18881var rStates = response.readyStates
18882
18883function decideMode (preferBinary, useFetch) {
18884 if (capability.fetch && useFetch) {
18885 return 'fetch'
18886 } else if (capability.mozchunkedarraybuffer) {
18887 return 'moz-chunked-arraybuffer'
18888 } else if (capability.msstream) {
18889 return 'ms-stream'
18890 } else if (capability.arraybuffer && preferBinary) {
18891 return 'arraybuffer'
18892 } else if (capability.vbArray && preferBinary) {
18893 return 'text:vbarray'
18894 } else {
18895 return 'text'
18896 }
18897}
18898
18899var ClientRequest = module.exports = function (opts) {
18900 var self = this
18901 stream.Writable.call(self)
18902
18903 self._opts = opts
18904 self._body = []
18905 self._headers = {}
18906 if (opts.auth)
18907 self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
18908 Object.keys(opts.headers).forEach(function (name) {
18909 self.setHeader(name, opts.headers[name])
18910 })
18911
18912 var preferBinary
18913 var useFetch = true
18914 if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
18915 // If the use of XHR should be preferred. Not typically needed.
18916 useFetch = false
18917 preferBinary = true
18918 } else if (opts.mode === 'prefer-streaming') {
18919 // If streaming is a high priority but binary compatibility and
18920 // the accuracy of the 'content-type' header aren't
18921 preferBinary = false
18922 } else if (opts.mode === 'allow-wrong-content-type') {
18923 // If streaming is more important than preserving the 'content-type' header
18924 preferBinary = !capability.overrideMimeType
18925 } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
18926 // Use binary if text streaming may corrupt data or the content-type header, or for speed
18927 preferBinary = true
18928 } else {
18929 throw new Error('Invalid value for opts.mode')
18930 }
18931 self._mode = decideMode(preferBinary, useFetch)
18932 self._fetchTimer = null
18933
18934 self.on('finish', function () {
18935 self._onFinish()
18936 })
18937}
18938
18939inherits(ClientRequest, stream.Writable)
18940
18941ClientRequest.prototype.setHeader = function (name, value) {
18942 var self = this
18943 var lowerName = name.toLowerCase()
18944 // This check is not necessary, but it prevents warnings from browsers about setting unsafe
18945 // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
18946 // http-browserify did it, so I will too.
18947 if (unsafeHeaders.indexOf(lowerName) !== -1)
18948 return
18949
18950 self._headers[lowerName] = {
18951 name: name,
18952 value: value
18953 }
18954}
18955
18956ClientRequest.prototype.getHeader = function (name) {
18957 var header = this._headers[name.toLowerCase()]
18958 if (header)
18959 return header.value
18960 return null
18961}
18962
18963ClientRequest.prototype.removeHeader = function (name) {
18964 var self = this
18965 delete self._headers[name.toLowerCase()]
18966}
18967
18968ClientRequest.prototype._onFinish = function () {
18969 var self = this
18970
18971 if (self._destroyed)
18972 return
18973 var opts = self._opts
18974
18975 var headersObj = self._headers
18976 var body = null
18977 if (opts.method !== 'GET' && opts.method !== 'HEAD') {
18978 if (capability.arraybuffer) {
18979 body = toArrayBuffer(Buffer.concat(self._body))
18980 } else if (capability.blobConstructor) {
18981 body = new global.Blob(self._body.map(function (buffer) {
18982 return toArrayBuffer(buffer)
18983 }), {
18984 type: (headersObj['content-type'] || {}).value || ''
18985 })
18986 } else {
18987 // get utf8 string
18988 body = Buffer.concat(self._body).toString()
18989 }
18990 }
18991
18992 // create flattened list of headers
18993 var headersList = []
18994 Object.keys(headersObj).forEach(function (keyName) {
18995 var name = headersObj[keyName].name
18996 var value = headersObj[keyName].value
18997 if (Array.isArray(value)) {
18998 value.forEach(function (v) {
18999 headersList.push([name, v])
19000 })
19001 } else {
19002 headersList.push([name, value])
19003 }
19004 })
19005
19006 if (self._mode === 'fetch') {
19007 var signal = null
19008 var fetchTimer = null
19009 if (capability.abortController) {
19010 var controller = new AbortController()
19011 signal = controller.signal
19012 self._fetchAbortController = controller
19013
19014 if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
19015 self._fetchTimer = global.setTimeout(function () {
19016 self.emit('requestTimeout')
19017 if (self._fetchAbortController)
19018 self._fetchAbortController.abort()
19019 }, opts.requestTimeout)
19020 }
19021 }
19022
19023 global.fetch(self._opts.url, {
19024 method: self._opts.method,
19025 headers: headersList,
19026 body: body || undefined,
19027 mode: 'cors',
19028 credentials: opts.withCredentials ? 'include' : 'same-origin',
19029 signal: signal
19030 }).then(function (response) {
19031 self._fetchResponse = response
19032 self._connect()
19033 }, function (reason) {
19034 global.clearTimeout(self._fetchTimer)
19035 if (!self._destroyed)
19036 self.emit('error', reason)
19037 })
19038 } else {
19039 var xhr = self._xhr = new global.XMLHttpRequest()
19040 try {
19041 xhr.open(self._opts.method, self._opts.url, true)
19042 } catch (err) {
19043 process.nextTick(function () {
19044 self.emit('error', err)
19045 })
19046 return
19047 }
19048
19049 // Can't set responseType on really old browsers
19050 if ('responseType' in xhr)
19051 xhr.responseType = self._mode.split(':')[0]
19052
19053 if ('withCredentials' in xhr)
19054 xhr.withCredentials = !!opts.withCredentials
19055
19056 if (self._mode === 'text' && 'overrideMimeType' in xhr)
19057 xhr.overrideMimeType('text/plain; charset=x-user-defined')
19058
19059 if ('requestTimeout' in opts) {
19060 xhr.timeout = opts.requestTimeout
19061 xhr.ontimeout = function () {
19062 self.emit('requestTimeout')
19063 }
19064 }
19065
19066 headersList.forEach(function (header) {
19067 xhr.setRequestHeader(header[0], header[1])
19068 })
19069
19070 self._response = null
19071 xhr.onreadystatechange = function () {
19072 switch (xhr.readyState) {
19073 case rStates.LOADING:
19074 case rStates.DONE:
19075 self._onXHRProgress()
19076 break
19077 }
19078 }
19079 // Necessary for streaming in Firefox, since xhr.response is ONLY defined
19080 // in onprogress, not in onreadystatechange with xhr.readyState = 3
19081 if (self._mode === 'moz-chunked-arraybuffer') {
19082 xhr.onprogress = function () {
19083 self._onXHRProgress()
19084 }
19085 }
19086
19087 xhr.onerror = function () {
19088 if (self._destroyed)
19089 return
19090 self.emit('error', new Error('XHR error'))
19091 }
19092
19093 try {
19094 xhr.send(body)
19095 } catch (err) {
19096 process.nextTick(function () {
19097 self.emit('error', err)
19098 })
19099 return
19100 }
19101 }
19102}
19103
19104/**
19105 * Checks if xhr.status is readable and non-zero, indicating no error.
19106 * Even though the spec says it should be available in readyState 3,
19107 * accessing it throws an exception in IE8
19108 */
19109function statusValid (xhr) {
19110 try {
19111 var status = xhr.status
19112 return (status !== null && status !== 0)
19113 } catch (e) {
19114 return false
19115 }
19116}
19117
19118ClientRequest.prototype._onXHRProgress = function () {
19119 var self = this
19120
19121 if (!statusValid(self._xhr) || self._destroyed)
19122 return
19123
19124 if (!self._response)
19125 self._connect()
19126
19127 self._response._onXHRProgress()
19128}
19129
19130ClientRequest.prototype._connect = function () {
19131 var self = this
19132
19133 if (self._destroyed)
19134 return
19135
19136 self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer)
19137 self._response.on('error', function(err) {
19138 self.emit('error', err)
19139 })
19140
19141 self.emit('response', self._response)
19142}
19143
19144ClientRequest.prototype._write = function (chunk, encoding, cb) {
19145 var self = this
19146
19147 self._body.push(chunk)
19148 cb()
19149}
19150
19151ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
19152 var self = this
19153 self._destroyed = true
19154 global.clearTimeout(self._fetchTimer)
19155 if (self._response)
19156 self._response._destroyed = true
19157 if (self._xhr)
19158 self._xhr.abort()
19159 else if (self._fetchAbortController)
19160 self._fetchAbortController.abort()
19161}
19162
19163ClientRequest.prototype.end = function (data, encoding, cb) {
19164 var self = this
19165 if (typeof data === 'function') {
19166 cb = data
19167 data = undefined
19168 }
19169
19170 stream.Writable.prototype.end.call(self, data, encoding, cb)
19171}
19172
19173ClientRequest.prototype.flushHeaders = function () {}
19174ClientRequest.prototype.setTimeout = function () {}
19175ClientRequest.prototype.setNoDelay = function () {}
19176ClientRequest.prototype.setSocketKeepAlive = function () {}
19177
19178// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
19179var unsafeHeaders = [
19180 'accept-charset',
19181 'accept-encoding',
19182 'access-control-request-headers',
19183 'access-control-request-method',
19184 'connection',
19185 'content-length',
19186 'cookie',
19187 'cookie2',
19188 'date',
19189 'dnt',
19190 'expect',
19191 'host',
19192 'keep-alive',
19193 'origin',
19194 'referer',
19195 'te',
19196 'trailer',
19197 'transfer-encoding',
19198 'upgrade',
19199 'via'
19200]
19201
19202}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
19203
19204},{"./capability":140,"./response":142,"_process":125,"buffer":9,"inherits":68,"readable-stream":137,"to-arraybuffer":147}],142:[function(require,module,exports){
19205(function (process,global,Buffer){
19206var capability = require('./capability')
19207var inherits = require('inherits')
19208var stream = require('readable-stream')
19209
19210var rStates = exports.readyStates = {
19211 UNSENT: 0,
19212 OPENED: 1,
19213 HEADERS_RECEIVED: 2,
19214 LOADING: 3,
19215 DONE: 4
19216}
19217
19218var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
19219 var self = this
19220 stream.Readable.call(self)
19221
19222 self._mode = mode
19223 self.headers = {}
19224 self.rawHeaders = []
19225 self.trailers = {}
19226 self.rawTrailers = []
19227
19228 // Fake the 'close' event, but only once 'end' fires
19229 self.on('end', function () {
19230 // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
19231 process.nextTick(function () {
19232 self.emit('close')
19233 })
19234 })
19235
19236 if (mode === 'fetch') {
19237 self._fetchResponse = response
19238
19239 self.url = response.url
19240 self.statusCode = response.status
19241 self.statusMessage = response.statusText
19242
19243 response.headers.forEach(function (header, key){
19244 self.headers[key.toLowerCase()] = header
19245 self.rawHeaders.push(key, header)
19246 })
19247
19248 if (capability.writableStream) {
19249 var writable = new WritableStream({
19250 write: function (chunk) {
19251 return new Promise(function (resolve, reject) {
19252 if (self._destroyed) {
19253 reject()
19254 } else if(self.push(new Buffer(chunk))) {
19255 resolve()
19256 } else {
19257 self._resumeFetch = resolve
19258 }
19259 })
19260 },
19261 close: function () {
19262 global.clearTimeout(fetchTimer)
19263 if (!self._destroyed)
19264 self.push(null)
19265 },
19266 abort: function (err) {
19267 if (!self._destroyed)
19268 self.emit('error', err)
19269 }
19270 })
19271
19272 try {
19273 response.body.pipeTo(writable).catch(function (err) {
19274 global.clearTimeout(fetchTimer)
19275 if (!self._destroyed)
19276 self.emit('error', err)
19277 })
19278 return
19279 } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
19280 }
19281 // fallback for when writableStream or pipeTo aren't available
19282 var reader = response.body.getReader()
19283 function read () {
19284 reader.read().then(function (result) {
19285 if (self._destroyed)
19286 return
19287 if (result.done) {
19288 global.clearTimeout(fetchTimer)
19289 self.push(null)
19290 return
19291 }
19292 self.push(new Buffer(result.value))
19293 read()
19294 }).catch(function (err) {
19295 global.clearTimeout(fetchTimer)
19296 if (!self._destroyed)
19297 self.emit('error', err)
19298 })
19299 }
19300 read()
19301 } else {
19302 self._xhr = xhr
19303 self._pos = 0
19304
19305 self.url = xhr.responseURL
19306 self.statusCode = xhr.status
19307 self.statusMessage = xhr.statusText
19308 var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
19309 headers.forEach(function (header) {
19310 var matches = header.match(/^([^:]+):\s*(.*)/)
19311 if (matches) {
19312 var key = matches[1].toLowerCase()
19313 if (key === 'set-cookie') {
19314 if (self.headers[key] === undefined) {
19315 self.headers[key] = []
19316 }
19317 self.headers[key].push(matches[2])
19318 } else if (self.headers[key] !== undefined) {
19319 self.headers[key] += ', ' + matches[2]
19320 } else {
19321 self.headers[key] = matches[2]
19322 }
19323 self.rawHeaders.push(matches[1], matches[2])
19324 }
19325 })
19326
19327 self._charset = 'x-user-defined'
19328 if (!capability.overrideMimeType) {
19329 var mimeType = self.rawHeaders['mime-type']
19330 if (mimeType) {
19331 var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
19332 if (charsetMatch) {
19333 self._charset = charsetMatch[1].toLowerCase()
19334 }
19335 }
19336 if (!self._charset)
19337 self._charset = 'utf-8' // best guess
19338 }
19339 }
19340}
19341
19342inherits(IncomingMessage, stream.Readable)
19343
19344IncomingMessage.prototype._read = function () {
19345 var self = this
19346
19347 var resolve = self._resumeFetch
19348 if (resolve) {
19349 self._resumeFetch = null
19350 resolve()
19351 }
19352}
19353
19354IncomingMessage.prototype._onXHRProgress = function () {
19355 var self = this
19356
19357 var xhr = self._xhr
19358
19359 var response = null
19360 switch (self._mode) {
19361 case 'text:vbarray': // For IE9
19362 if (xhr.readyState !== rStates.DONE)
19363 break
19364 try {
19365 // This fails in IE8
19366 response = new global.VBArray(xhr.responseBody).toArray()
19367 } catch (e) {}
19368 if (response !== null) {
19369 self.push(new Buffer(response))
19370 break
19371 }
19372 // Falls through in IE8
19373 case 'text':
19374 try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
19375 response = xhr.responseText
19376 } catch (e) {
19377 self._mode = 'text:vbarray'
19378 break
19379 }
19380 if (response.length > self._pos) {
19381 var newData = response.substr(self._pos)
19382 if (self._charset === 'x-user-defined') {
19383 var buffer = new Buffer(newData.length)
19384 for (var i = 0; i < newData.length; i++)
19385 buffer[i] = newData.charCodeAt(i) & 0xff
19386
19387 self.push(buffer)
19388 } else {
19389 self.push(newData, self._charset)
19390 }
19391 self._pos = response.length
19392 }
19393 break
19394 case 'arraybuffer':
19395 if (xhr.readyState !== rStates.DONE || !xhr.response)
19396 break
19397 response = xhr.response
19398 self.push(new Buffer(new Uint8Array(response)))
19399 break
19400 case 'moz-chunked-arraybuffer': // take whole
19401 response = xhr.response
19402 if (xhr.readyState !== rStates.LOADING || !response)
19403 break
19404 self.push(new Buffer(new Uint8Array(response)))
19405 break
19406 case 'ms-stream':
19407 response = xhr.response
19408 if (xhr.readyState !== rStates.LOADING)
19409 break
19410 var reader = new global.MSStreamReader()
19411 reader.onprogress = function () {
19412 if (reader.result.byteLength > self._pos) {
19413 self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
19414 self._pos = reader.result.byteLength
19415 }
19416 }
19417 reader.onload = function () {
19418 self.push(null)
19419 }
19420 // reader.onerror = ??? // TODO: this
19421 reader.readAsArrayBuffer(response)
19422 break
19423 }
19424
19425 // The ms-stream case handles end separately in reader.onload()
19426 if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
19427 self.push(null)
19428 }
19429}
19430
19431}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
19432
19433},{"./capability":140,"_process":125,"buffer":9,"inherits":68,"readable-stream":137}],143:[function(require,module,exports){
19434// Copyright Joyent, Inc. and other Node contributors.
19435//
19436// Permission is hereby granted, free of charge, to any person obtaining a
19437// copy of this software and associated documentation files (the
19438// "Software"), to deal in the Software without restriction, including
19439// without limitation the rights to use, copy, modify, merge, publish,
19440// distribute, sublicense, and/or sell copies of the Software, and to permit
19441// persons to whom the Software is furnished to do so, subject to the
19442// following conditions:
19443//
19444// The above copyright notice and this permission notice shall be included
19445// in all copies or substantial portions of the Software.
19446//
19447// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19448// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19449// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19450// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19451// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19452// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19453// USE OR OTHER DEALINGS IN THE SOFTWARE.
19454
19455'use strict';
19456
19457/*<replacement>*/
19458
19459var Buffer = require('safe-buffer').Buffer;
19460/*</replacement>*/
19461
19462var isEncoding = Buffer.isEncoding || function (encoding) {
19463 encoding = '' + encoding;
19464 switch (encoding && encoding.toLowerCase()) {
19465 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
19466 return true;
19467 default:
19468 return false;
19469 }
19470};
19471
19472function _normalizeEncoding(enc) {
19473 if (!enc) return 'utf8';
19474 var retried;
19475 while (true) {
19476 switch (enc) {
19477 case 'utf8':
19478 case 'utf-8':
19479 return 'utf8';
19480 case 'ucs2':
19481 case 'ucs-2':
19482 case 'utf16le':
19483 case 'utf-16le':
19484 return 'utf16le';
19485 case 'latin1':
19486 case 'binary':
19487 return 'latin1';
19488 case 'base64':
19489 case 'ascii':
19490 case 'hex':
19491 return enc;
19492 default:
19493 if (retried) return; // undefined
19494 enc = ('' + enc).toLowerCase();
19495 retried = true;
19496 }
19497 }
19498};
19499
19500// Do not cache `Buffer.isEncoding` when checking encoding names as some
19501// modules monkey-patch it to support additional encodings
19502function normalizeEncoding(enc) {
19503 var nenc = _normalizeEncoding(enc);
19504 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
19505 return nenc || enc;
19506}
19507
19508// StringDecoder provides an interface for efficiently splitting a series of
19509// buffers into a series of JS strings without breaking apart multi-byte
19510// characters.
19511exports.StringDecoder = StringDecoder;
19512function StringDecoder(encoding) {
19513 this.encoding = normalizeEncoding(encoding);
19514 var nb;
19515 switch (this.encoding) {
19516 case 'utf16le':
19517 this.text = utf16Text;
19518 this.end = utf16End;
19519 nb = 4;
19520 break;
19521 case 'utf8':
19522 this.fillLast = utf8FillLast;
19523 nb = 4;
19524 break;
19525 case 'base64':
19526 this.text = base64Text;
19527 this.end = base64End;
19528 nb = 3;
19529 break;
19530 default:
19531 this.write = simpleWrite;
19532 this.end = simpleEnd;
19533 return;
19534 }
19535 this.lastNeed = 0;
19536 this.lastTotal = 0;
19537 this.lastChar = Buffer.allocUnsafe(nb);
19538}
19539
19540StringDecoder.prototype.write = function (buf) {
19541 if (buf.length === 0) return '';
19542 var r;
19543 var i;
19544 if (this.lastNeed) {
19545 r = this.fillLast(buf);
19546 if (r === undefined) return '';
19547 i = this.lastNeed;
19548 this.lastNeed = 0;
19549 } else {
19550 i = 0;
19551 }
19552 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
19553 return r || '';
19554};
19555
19556StringDecoder.prototype.end = utf8End;
19557
19558// Returns only complete characters in a Buffer
19559StringDecoder.prototype.text = utf8Text;
19560
19561// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
19562StringDecoder.prototype.fillLast = function (buf) {
19563 if (this.lastNeed <= buf.length) {
19564 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
19565 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
19566 }
19567 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
19568 this.lastNeed -= buf.length;
19569};
19570
19571// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
19572// continuation byte. If an invalid byte is detected, -2 is returned.
19573function utf8CheckByte(byte) {
19574 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
19575 return byte >> 6 === 0x02 ? -1 : -2;
19576}
19577
19578// Checks at most 3 bytes at the end of a Buffer in order to detect an
19579// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
19580// needed to complete the UTF-8 character (if applicable) are returned.
19581function utf8CheckIncomplete(self, buf, i) {
19582 var j = buf.length - 1;
19583 if (j < i) return 0;
19584 var nb = utf8CheckByte(buf[j]);
19585 if (nb >= 0) {
19586 if (nb > 0) self.lastNeed = nb - 1;
19587 return nb;
19588 }
19589 if (--j < i || nb === -2) return 0;
19590 nb = utf8CheckByte(buf[j]);
19591 if (nb >= 0) {
19592 if (nb > 0) self.lastNeed = nb - 2;
19593 return nb;
19594 }
19595 if (--j < i || nb === -2) return 0;
19596 nb = utf8CheckByte(buf[j]);
19597 if (nb >= 0) {
19598 if (nb > 0) {
19599 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
19600 }
19601 return nb;
19602 }
19603 return 0;
19604}
19605
19606// Validates as many continuation bytes for a multi-byte UTF-8 character as
19607// needed or are available. If we see a non-continuation byte where we expect
19608// one, we "replace" the validated continuation bytes we've seen so far with
19609// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
19610// behavior. The continuation byte check is included three times in the case
19611// where all of the continuation bytes for a character exist in the same buffer.
19612// It is also done this way as a slight performance increase instead of using a
19613// loop.
19614function utf8CheckExtraBytes(self, buf, p) {
19615 if ((buf[0] & 0xC0) !== 0x80) {
19616 self.lastNeed = 0;
19617 return '\ufffd';
19618 }
19619 if (self.lastNeed > 1 && buf.length > 1) {
19620 if ((buf[1] & 0xC0) !== 0x80) {
19621 self.lastNeed = 1;
19622 return '\ufffd';
19623 }
19624 if (self.lastNeed > 2 && buf.length > 2) {
19625 if ((buf[2] & 0xC0) !== 0x80) {
19626 self.lastNeed = 2;
19627 return '\ufffd';
19628 }
19629 }
19630 }
19631}
19632
19633// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
19634function utf8FillLast(buf) {
19635 var p = this.lastTotal - this.lastNeed;
19636 var r = utf8CheckExtraBytes(this, buf, p);
19637 if (r !== undefined) return r;
19638 if (this.lastNeed <= buf.length) {
19639 buf.copy(this.lastChar, p, 0, this.lastNeed);
19640 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
19641 }
19642 buf.copy(this.lastChar, p, 0, buf.length);
19643 this.lastNeed -= buf.length;
19644}
19645
19646// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
19647// partial character, the character's bytes are buffered until the required
19648// number of bytes are available.
19649function utf8Text(buf, i) {
19650 var total = utf8CheckIncomplete(this, buf, i);
19651 if (!this.lastNeed) return buf.toString('utf8', i);
19652 this.lastTotal = total;
19653 var end = buf.length - (total - this.lastNeed);
19654 buf.copy(this.lastChar, 0, end);
19655 return buf.toString('utf8', i, end);
19656}
19657
19658// For UTF-8, a replacement character is added when ending on a partial
19659// character.
19660function utf8End(buf) {
19661 var r = buf && buf.length ? this.write(buf) : '';
19662 if (this.lastNeed) return r + '\ufffd';
19663 return r;
19664}
19665
19666// UTF-16LE typically needs two bytes per character, but even if we have an even
19667// number of bytes available, we need to check if we end on a leading/high
19668// surrogate. In that case, we need to wait for the next two bytes in order to
19669// decode the last character properly.
19670function utf16Text(buf, i) {
19671 if ((buf.length - i) % 2 === 0) {
19672 var r = buf.toString('utf16le', i);
19673 if (r) {
19674 var c = r.charCodeAt(r.length - 1);
19675 if (c >= 0xD800 && c <= 0xDBFF) {
19676 this.lastNeed = 2;
19677 this.lastTotal = 4;
19678 this.lastChar[0] = buf[buf.length - 2];
19679 this.lastChar[1] = buf[buf.length - 1];
19680 return r.slice(0, -1);
19681 }
19682 }
19683 return r;
19684 }
19685 this.lastNeed = 1;
19686 this.lastTotal = 2;
19687 this.lastChar[0] = buf[buf.length - 1];
19688 return buf.toString('utf16le', i, buf.length - 1);
19689}
19690
19691// For UTF-16LE we do not explicitly append special replacement characters if we
19692// end on a partial character, we simply let v8 handle that.
19693function utf16End(buf) {
19694 var r = buf && buf.length ? this.write(buf) : '';
19695 if (this.lastNeed) {
19696 var end = this.lastTotal - this.lastNeed;
19697 return r + this.lastChar.toString('utf16le', 0, end);
19698 }
19699 return r;
19700}
19701
19702function base64Text(buf, i) {
19703 var n = (buf.length - i) % 3;
19704 if (n === 0) return buf.toString('base64', i);
19705 this.lastNeed = 3 - n;
19706 this.lastTotal = 3;
19707 if (n === 1) {
19708 this.lastChar[0] = buf[buf.length - 1];
19709 } else {
19710 this.lastChar[0] = buf[buf.length - 2];
19711 this.lastChar[1] = buf[buf.length - 1];
19712 }
19713 return buf.toString('base64', i, buf.length - n);
19714}
19715
19716function base64End(buf) {
19717 var r = buf && buf.length ? this.write(buf) : '';
19718 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
19719 return r;
19720}
19721
19722// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
19723function simpleWrite(buf) {
19724 return buf.toString(this.encoding);
19725}
19726
19727function simpleEnd(buf) {
19728 return buf && buf.length ? this.write(buf) : '';
19729}
19730},{"safe-buffer":138}],144:[function(require,module,exports){
19731"use strict";
19732
19733module.exports = [
19734 "get", "put", "post", "delete", "options", "head", "patch"
19735];
19736
19737},{}],145:[function(require,module,exports){
19738module.exports={
19739 "title": "A JSON Schema for Swagger 2.0 API.",
19740 "id": "http://swagger.io/v2/schema.json#",
19741 "$schema": "http://json-schema.org/draft-04/schema#",
19742 "type": "object",
19743 "required": [
19744 "swagger",
19745 "info",
19746 "paths"
19747 ],
19748 "additionalProperties": false,
19749 "patternProperties": {
19750 "^x-": {
19751 "$ref": "#/definitions/vendorExtension"
19752 }
19753 },
19754 "properties": {
19755 "swagger": {
19756 "type": "string",
19757 "enum": [
19758 "2.0"
19759 ],
19760 "description": "The Swagger version of this document."
19761 },
19762 "info": {
19763 "$ref": "#/definitions/info"
19764 },
19765 "host": {
19766 "type": "string",
19767 "pattern": "^[^{}/ :\\\\]+(?::\\d+)?$",
19768 "description": "The host (name or ip) of the API. Example: 'swagger.io'"
19769 },
19770 "basePath": {
19771 "type": "string",
19772 "pattern": "^/",
19773 "description": "The base path to the API. Example: '/api'."
19774 },
19775 "schemes": {
19776 "$ref": "#/definitions/schemesList"
19777 },
19778 "consumes": {
19779 "description": "A list of MIME types accepted by the API.",
19780 "$ref": "#/definitions/mediaTypeList"
19781 },
19782 "produces": {
19783 "description": "A list of MIME types the API can produce.",
19784 "$ref": "#/definitions/mediaTypeList"
19785 },
19786 "paths": {
19787 "$ref": "#/definitions/paths"
19788 },
19789 "definitions": {
19790 "$ref": "#/definitions/definitions"
19791 },
19792 "parameters": {
19793 "$ref": "#/definitions/parameterDefinitions"
19794 },
19795 "responses": {
19796 "$ref": "#/definitions/responseDefinitions"
19797 },
19798 "security": {
19799 "$ref": "#/definitions/security"
19800 },
19801 "securityDefinitions": {
19802 "$ref": "#/definitions/securityDefinitions"
19803 },
19804 "tags": {
19805 "type": "array",
19806 "items": {
19807 "$ref": "#/definitions/tag"
19808 },
19809 "uniqueItems": true
19810 },
19811 "externalDocs": {
19812 "$ref": "#/definitions/externalDocs"
19813 }
19814 },
19815 "definitions": {
19816 "info": {
19817 "type": "object",
19818 "description": "General information about the API.",
19819 "required": [
19820 "version",
19821 "title"
19822 ],
19823 "additionalProperties": false,
19824 "patternProperties": {
19825 "^x-": {
19826 "$ref": "#/definitions/vendorExtension"
19827 }
19828 },
19829 "properties": {
19830 "title": {
19831 "type": "string",
19832 "description": "A unique and precise title of the API."
19833 },
19834 "version": {
19835 "type": "string",
19836 "description": "A semantic version number of the API."
19837 },
19838 "description": {
19839 "type": "string",
19840 "description": "A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed."
19841 },
19842 "termsOfService": {
19843 "type": "string",
19844 "description": "The terms of service for the API."
19845 },
19846 "contact": {
19847 "$ref": "#/definitions/contact"
19848 },
19849 "license": {
19850 "$ref": "#/definitions/license"
19851 }
19852 }
19853 },
19854 "contact": {
19855 "type": "object",
19856 "description": "Contact information for the owners of the API.",
19857 "additionalProperties": false,
19858 "properties": {
19859 "name": {
19860 "type": "string",
19861 "description": "The identifying name of the contact person/organization."
19862 },
19863 "url": {
19864 "type": "string",
19865 "description": "The URL pointing to the contact information.",
19866 "format": "uri"
19867 },
19868 "email": {
19869 "type": "string",
19870 "description": "The email address of the contact person/organization.",
19871 "format": "email"
19872 }
19873 },
19874 "patternProperties": {
19875 "^x-": {
19876 "$ref": "#/definitions/vendorExtension"
19877 }
19878 }
19879 },
19880 "license": {
19881 "type": "object",
19882 "required": [
19883 "name"
19884 ],
19885 "additionalProperties": false,
19886 "properties": {
19887 "name": {
19888 "type": "string",
19889 "description": "The name of the license type. It's encouraged to use an OSI compatible license."
19890 },
19891 "url": {
19892 "type": "string",
19893 "description": "The URL pointing to the license.",
19894 "format": "uri"
19895 }
19896 },
19897 "patternProperties": {
19898 "^x-": {
19899 "$ref": "#/definitions/vendorExtension"
19900 }
19901 }
19902 },
19903 "paths": {
19904 "type": "object",
19905 "description": "Relative paths to the individual endpoints. They must be relative to the 'basePath'.",
19906 "patternProperties": {
19907 "^x-": {
19908 "$ref": "#/definitions/vendorExtension"
19909 },
19910 "^/": {
19911 "$ref": "#/definitions/pathItem"
19912 }
19913 },
19914 "additionalProperties": false
19915 },
19916 "definitions": {
19917 "type": "object",
19918 "additionalProperties": {
19919 "$ref": "#/definitions/schema"
19920 },
19921 "description": "One or more JSON objects describing the schemas being consumed and produced by the API."
19922 },
19923 "parameterDefinitions": {
19924 "type": "object",
19925 "additionalProperties": {
19926 "$ref": "#/definitions/parameter"
19927 },
19928 "description": "One or more JSON representations for parameters"
19929 },
19930 "responseDefinitions": {
19931 "type": "object",
19932 "additionalProperties": {
19933 "$ref": "#/definitions/response"
19934 },
19935 "description": "One or more JSON representations for parameters"
19936 },
19937 "externalDocs": {
19938 "type": "object",
19939 "additionalProperties": false,
19940 "description": "information about external documentation",
19941 "required": [
19942 "url"
19943 ],
19944 "properties": {
19945 "description": {
19946 "type": "string"
19947 },
19948 "url": {
19949 "type": "string",
19950 "format": "uri"
19951 }
19952 },
19953 "patternProperties": {
19954 "^x-": {
19955 "$ref": "#/definitions/vendorExtension"
19956 }
19957 }
19958 },
19959 "examples": {
19960 "type": "object",
19961 "additionalProperties": true
19962 },
19963 "mimeType": {
19964 "type": "string",
19965 "description": "The MIME type of the HTTP message."
19966 },
19967 "operation": {
19968 "type": "object",
19969 "required": [
19970 "responses"
19971 ],
19972 "additionalProperties": false,
19973 "patternProperties": {
19974 "^x-": {
19975 "$ref": "#/definitions/vendorExtension"
19976 }
19977 },
19978 "properties": {
19979 "tags": {
19980 "type": "array",
19981 "items": {
19982 "type": "string"
19983 },
19984 "uniqueItems": true
19985 },
19986 "summary": {
19987 "type": "string",
19988 "description": "A brief summary of the operation."
19989 },
19990 "description": {
19991 "type": "string",
19992 "description": "A longer description of the operation, GitHub Flavored Markdown is allowed."
19993 },
19994 "externalDocs": {
19995 "$ref": "#/definitions/externalDocs"
19996 },
19997 "operationId": {
19998 "type": "string",
19999 "description": "A unique identifier of the operation."
20000 },
20001 "produces": {
20002 "description": "A list of MIME types the API can produce.",
20003 "$ref": "#/definitions/mediaTypeList"
20004 },
20005 "consumes": {
20006 "description": "A list of MIME types the API can consume.",
20007 "$ref": "#/definitions/mediaTypeList"
20008 },
20009 "parameters": {
20010 "$ref": "#/definitions/parametersList"
20011 },
20012 "responses": {
20013 "$ref": "#/definitions/responses"
20014 },
20015 "schemes": {
20016 "$ref": "#/definitions/schemesList"
20017 },
20018 "deprecated": {
20019 "type": "boolean",
20020 "default": false
20021 },
20022 "security": {
20023 "$ref": "#/definitions/security"
20024 }
20025 }
20026 },
20027 "pathItem": {
20028 "type": "object",
20029 "additionalProperties": false,
20030 "patternProperties": {
20031 "^x-": {
20032 "$ref": "#/definitions/vendorExtension"
20033 }
20034 },
20035 "properties": {
20036 "$ref": {
20037 "type": "string"
20038 },
20039 "get": {
20040 "$ref": "#/definitions/operation"
20041 },
20042 "put": {
20043 "$ref": "#/definitions/operation"
20044 },
20045 "post": {
20046 "$ref": "#/definitions/operation"
20047 },
20048 "delete": {
20049 "$ref": "#/definitions/operation"
20050 },
20051 "options": {
20052 "$ref": "#/definitions/operation"
20053 },
20054 "head": {
20055 "$ref": "#/definitions/operation"
20056 },
20057 "patch": {
20058 "$ref": "#/definitions/operation"
20059 },
20060 "parameters": {
20061 "$ref": "#/definitions/parametersList"
20062 }
20063 }
20064 },
20065 "responses": {
20066 "type": "object",
20067 "description": "Response objects names can either be any valid HTTP status code or 'default'.",
20068 "minProperties": 1,
20069 "additionalProperties": false,
20070 "patternProperties": {
20071 "^([0-9]{3})$|^(default)$": {
20072 "$ref": "#/definitions/responseValue"
20073 },
20074 "^x-": {
20075 "$ref": "#/definitions/vendorExtension"
20076 }
20077 },
20078 "not": {
20079 "type": "object",
20080 "additionalProperties": false,
20081 "patternProperties": {
20082 "^x-": {
20083 "$ref": "#/definitions/vendorExtension"
20084 }
20085 }
20086 }
20087 },
20088 "responseValue": {
20089 "oneOf": [
20090 {
20091 "$ref": "#/definitions/response"
20092 },
20093 {
20094 "$ref": "#/definitions/jsonReference"
20095 }
20096 ]
20097 },
20098 "response": {
20099 "type": "object",
20100 "required": [
20101 "description"
20102 ],
20103 "properties": {
20104 "description": {
20105 "type": "string"
20106 },
20107 "schema": {
20108 "oneOf": [
20109 {
20110 "$ref": "#/definitions/schema"
20111 },
20112 {
20113 "$ref": "#/definitions/fileSchema"
20114 }
20115 ]
20116 },
20117 "headers": {
20118 "$ref": "#/definitions/headers"
20119 },
20120 "examples": {
20121 "$ref": "#/definitions/examples"
20122 }
20123 },
20124 "additionalProperties": false,
20125 "patternProperties": {
20126 "^x-": {
20127 "$ref": "#/definitions/vendorExtension"
20128 }
20129 }
20130 },
20131 "headers": {
20132 "type": "object",
20133 "additionalProperties": {
20134 "$ref": "#/definitions/header"
20135 }
20136 },
20137 "header": {
20138 "type": "object",
20139 "additionalProperties": false,
20140 "required": [
20141 "type"
20142 ],
20143 "properties": {
20144 "type": {
20145 "type": "string",
20146 "enum": [
20147 "string",
20148 "number",
20149 "integer",
20150 "boolean",
20151 "array"
20152 ]
20153 },
20154 "format": {
20155 "type": "string"
20156 },
20157 "items": {
20158 "$ref": "#/definitions/primitivesItems"
20159 },
20160 "collectionFormat": {
20161 "$ref": "#/definitions/collectionFormat"
20162 },
20163 "default": {
20164 "$ref": "#/definitions/default"
20165 },
20166 "maximum": {
20167 "$ref": "#/definitions/maximum"
20168 },
20169 "exclusiveMaximum": {
20170 "$ref": "#/definitions/exclusiveMaximum"
20171 },
20172 "minimum": {
20173 "$ref": "#/definitions/minimum"
20174 },
20175 "exclusiveMinimum": {
20176 "$ref": "#/definitions/exclusiveMinimum"
20177 },
20178 "maxLength": {
20179 "$ref": "#/definitions/maxLength"
20180 },
20181 "minLength": {
20182 "$ref": "#/definitions/minLength"
20183 },
20184 "pattern": {
20185 "$ref": "#/definitions/pattern"
20186 },
20187 "maxItems": {
20188 "$ref": "#/definitions/maxItems"
20189 },
20190 "minItems": {
20191 "$ref": "#/definitions/minItems"
20192 },
20193 "uniqueItems": {
20194 "$ref": "#/definitions/uniqueItems"
20195 },
20196 "enum": {
20197 "$ref": "#/definitions/enum"
20198 },
20199 "multipleOf": {
20200 "$ref": "#/definitions/multipleOf"
20201 },
20202 "description": {
20203 "type": "string"
20204 }
20205 },
20206 "patternProperties": {
20207 "^x-": {
20208 "$ref": "#/definitions/vendorExtension"
20209 }
20210 }
20211 },
20212 "vendorExtension": {
20213 "description": "Any property starting with x- is valid.",
20214 "additionalProperties": true,
20215 "additionalItems": true
20216 },
20217 "bodyParameter": {
20218 "type": "object",
20219 "required": [
20220 "name",
20221 "in",
20222 "schema"
20223 ],
20224 "patternProperties": {
20225 "^x-": {
20226 "$ref": "#/definitions/vendorExtension"
20227 }
20228 },
20229 "properties": {
20230 "description": {
20231 "type": "string",
20232 "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
20233 },
20234 "name": {
20235 "type": "string",
20236 "description": "The name of the parameter."
20237 },
20238 "in": {
20239 "type": "string",
20240 "description": "Determines the location of the parameter.",
20241 "enum": [
20242 "body"
20243 ]
20244 },
20245 "required": {
20246 "type": "boolean",
20247 "description": "Determines whether or not this parameter is required or optional.",
20248 "default": false
20249 },
20250 "schema": {
20251 "$ref": "#/definitions/schema"
20252 }
20253 },
20254 "additionalProperties": false
20255 },
20256 "headerParameterSubSchema": {
20257 "additionalProperties": false,
20258 "patternProperties": {
20259 "^x-": {
20260 "$ref": "#/definitions/vendorExtension"
20261 }
20262 },
20263 "properties": {
20264 "required": {
20265 "type": "boolean",
20266 "description": "Determines whether or not this parameter is required or optional.",
20267 "default": false
20268 },
20269 "in": {
20270 "type": "string",
20271 "description": "Determines the location of the parameter.",
20272 "enum": [
20273 "header"
20274 ]
20275 },
20276 "description": {
20277 "type": "string",
20278 "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
20279 },
20280 "name": {
20281 "type": "string",
20282 "description": "The name of the parameter."
20283 },
20284 "type": {
20285 "type": "string",
20286 "enum": [
20287 "string",
20288 "number",
20289 "boolean",
20290 "integer",
20291 "array"
20292 ]
20293 },
20294 "format": {
20295 "type": "string"
20296 },
20297 "items": {
20298 "$ref": "#/definitions/primitivesItems"
20299 },
20300 "collectionFormat": {
20301 "$ref": "#/definitions/collectionFormat"
20302 },
20303 "default": {
20304 "$ref": "#/definitions/default"
20305 },
20306 "maximum": {
20307 "$ref": "#/definitions/maximum"
20308 },
20309 "exclusiveMaximum": {
20310 "$ref": "#/definitions/exclusiveMaximum"
20311 },
20312 "minimum": {
20313 "$ref": "#/definitions/minimum"
20314 },
20315 "exclusiveMinimum": {
20316 "$ref": "#/definitions/exclusiveMinimum"
20317 },
20318 "maxLength": {
20319 "$ref": "#/definitions/maxLength"
20320 },
20321 "minLength": {
20322 "$ref": "#/definitions/minLength"
20323 },
20324 "pattern": {
20325 "$ref": "#/definitions/pattern"
20326 },
20327 "maxItems": {
20328 "$ref": "#/definitions/maxItems"
20329 },
20330 "minItems": {
20331 "$ref": "#/definitions/minItems"
20332 },
20333 "uniqueItems": {
20334 "$ref": "#/definitions/uniqueItems"
20335 },
20336 "enum": {
20337 "$ref": "#/definitions/enum"
20338 },
20339 "multipleOf": {
20340 "$ref": "#/definitions/multipleOf"
20341 }
20342 }
20343 },
20344 "queryParameterSubSchema": {
20345 "additionalProperties": false,
20346 "patternProperties": {
20347 "^x-": {
20348 "$ref": "#/definitions/vendorExtension"
20349 }
20350 },
20351 "properties": {
20352 "required": {
20353 "type": "boolean",
20354 "description": "Determines whether or not this parameter is required or optional.",
20355 "default": false
20356 },
20357 "in": {
20358 "type": "string",
20359 "description": "Determines the location of the parameter.",
20360 "enum": [
20361 "query"
20362 ]
20363 },
20364 "description": {
20365 "type": "string",
20366 "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
20367 },
20368 "name": {
20369 "type": "string",
20370 "description": "The name of the parameter."
20371 },
20372 "allowEmptyValue": {
20373 "type": "boolean",
20374 "default": false,
20375 "description": "allows sending a parameter by name only or with an empty value."
20376 },
20377 "type": {
20378 "type": "string",
20379 "enum": [
20380 "string",
20381 "number",
20382 "boolean",
20383 "integer",
20384 "array"
20385 ]
20386 },
20387 "format": {
20388 "type": "string"
20389 },
20390 "items": {
20391 "$ref": "#/definitions/primitivesItems"
20392 },
20393 "collectionFormat": {
20394 "$ref": "#/definitions/collectionFormatWithMulti"
20395 },
20396 "default": {
20397 "$ref": "#/definitions/default"
20398 },
20399 "maximum": {
20400 "$ref": "#/definitions/maximum"
20401 },
20402 "exclusiveMaximum": {
20403 "$ref": "#/definitions/exclusiveMaximum"
20404 },
20405 "minimum": {
20406 "$ref": "#/definitions/minimum"
20407 },
20408 "exclusiveMinimum": {
20409 "$ref": "#/definitions/exclusiveMinimum"
20410 },
20411 "maxLength": {
20412 "$ref": "#/definitions/maxLength"
20413 },
20414 "minLength": {
20415 "$ref": "#/definitions/minLength"
20416 },
20417 "pattern": {
20418 "$ref": "#/definitions/pattern"
20419 },
20420 "maxItems": {
20421 "$ref": "#/definitions/maxItems"
20422 },
20423 "minItems": {
20424 "$ref": "#/definitions/minItems"
20425 },
20426 "uniqueItems": {
20427 "$ref": "#/definitions/uniqueItems"
20428 },
20429 "enum": {
20430 "$ref": "#/definitions/enum"
20431 },
20432 "multipleOf": {
20433 "$ref": "#/definitions/multipleOf"
20434 }
20435 }
20436 },
20437 "formDataParameterSubSchema": {
20438 "additionalProperties": false,
20439 "patternProperties": {
20440 "^x-": {
20441 "$ref": "#/definitions/vendorExtension"
20442 }
20443 },
20444 "properties": {
20445 "required": {
20446 "type": "boolean",
20447 "description": "Determines whether or not this parameter is required or optional.",
20448 "default": false
20449 },
20450 "in": {
20451 "type": "string",
20452 "description": "Determines the location of the parameter.",
20453 "enum": [
20454 "formData"
20455 ]
20456 },
20457 "description": {
20458 "type": "string",
20459 "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
20460 },
20461 "name": {
20462 "type": "string",
20463 "description": "The name of the parameter."
20464 },
20465 "allowEmptyValue": {
20466 "type": "boolean",
20467 "default": false,
20468 "description": "allows sending a parameter by name only or with an empty value."
20469 },
20470 "type": {
20471 "type": "string",
20472 "enum": [
20473 "string",
20474 "number",
20475 "boolean",
20476 "integer",
20477 "array",
20478 "file"
20479 ]
20480 },
20481 "format": {
20482 "type": "string"
20483 },
20484 "items": {
20485 "$ref": "#/definitions/primitivesItems"
20486 },
20487 "collectionFormat": {
20488 "$ref": "#/definitions/collectionFormatWithMulti"
20489 },
20490 "default": {
20491 "$ref": "#/definitions/default"
20492 },
20493 "maximum": {
20494 "$ref": "#/definitions/maximum"
20495 },
20496 "exclusiveMaximum": {
20497 "$ref": "#/definitions/exclusiveMaximum"
20498 },
20499 "minimum": {
20500 "$ref": "#/definitions/minimum"
20501 },
20502 "exclusiveMinimum": {
20503 "$ref": "#/definitions/exclusiveMinimum"
20504 },
20505 "maxLength": {
20506 "$ref": "#/definitions/maxLength"
20507 },
20508 "minLength": {
20509 "$ref": "#/definitions/minLength"
20510 },
20511 "pattern": {
20512 "$ref": "#/definitions/pattern"
20513 },
20514 "maxItems": {
20515 "$ref": "#/definitions/maxItems"
20516 },
20517 "minItems": {
20518 "$ref": "#/definitions/minItems"
20519 },
20520 "uniqueItems": {
20521 "$ref": "#/definitions/uniqueItems"
20522 },
20523 "enum": {
20524 "$ref": "#/definitions/enum"
20525 },
20526 "multipleOf": {
20527 "$ref": "#/definitions/multipleOf"
20528 }
20529 }
20530 },
20531 "pathParameterSubSchema": {
20532 "additionalProperties": false,
20533 "patternProperties": {
20534 "^x-": {
20535 "$ref": "#/definitions/vendorExtension"
20536 }
20537 },
20538 "required": [
20539 "required"
20540 ],
20541 "properties": {
20542 "required": {
20543 "type": "boolean",
20544 "enum": [
20545 true
20546 ],
20547 "description": "Determines whether or not this parameter is required or optional."
20548 },
20549 "in": {
20550 "type": "string",
20551 "description": "Determines the location of the parameter.",
20552 "enum": [
20553 "path"
20554 ]
20555 },
20556 "description": {
20557 "type": "string",
20558 "description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
20559 },
20560 "name": {
20561 "type": "string",
20562 "description": "The name of the parameter."
20563 },
20564 "type": {
20565 "type": "string",
20566 "enum": [
20567 "string",
20568 "number",
20569 "boolean",
20570 "integer",
20571 "array"
20572 ]
20573 },
20574 "format": {
20575 "type": "string"
20576 },
20577 "items": {
20578 "$ref": "#/definitions/primitivesItems"
20579 },
20580 "collectionFormat": {
20581 "$ref": "#/definitions/collectionFormat"
20582 },
20583 "default": {
20584 "$ref": "#/definitions/default"
20585 },
20586 "maximum": {
20587 "$ref": "#/definitions/maximum"
20588 },
20589 "exclusiveMaximum": {
20590 "$ref": "#/definitions/exclusiveMaximum"
20591 },
20592 "minimum": {
20593 "$ref": "#/definitions/minimum"
20594 },
20595 "exclusiveMinimum": {
20596 "$ref": "#/definitions/exclusiveMinimum"
20597 },
20598 "maxLength": {
20599 "$ref": "#/definitions/maxLength"
20600 },
20601 "minLength": {
20602 "$ref": "#/definitions/minLength"
20603 },
20604 "pattern": {
20605 "$ref": "#/definitions/pattern"
20606 },
20607 "maxItems": {
20608 "$ref": "#/definitions/maxItems"
20609 },
20610 "minItems": {
20611 "$ref": "#/definitions/minItems"
20612 },
20613 "uniqueItems": {
20614 "$ref": "#/definitions/uniqueItems"
20615 },
20616 "enum": {
20617 "$ref": "#/definitions/enum"
20618 },
20619 "multipleOf": {
20620 "$ref": "#/definitions/multipleOf"
20621 }
20622 }
20623 },
20624 "nonBodyParameter": {
20625 "type": "object",
20626 "required": [
20627 "name",
20628 "in",
20629 "type"
20630 ],
20631 "oneOf": [
20632 {
20633 "$ref": "#/definitions/headerParameterSubSchema"
20634 },
20635 {
20636 "$ref": "#/definitions/formDataParameterSubSchema"
20637 },
20638 {
20639 "$ref": "#/definitions/queryParameterSubSchema"
20640 },
20641 {
20642 "$ref": "#/definitions/pathParameterSubSchema"
20643 }
20644 ]
20645 },
20646 "parameter": {
20647 "oneOf": [
20648 {
20649 "$ref": "#/definitions/bodyParameter"
20650 },
20651 {
20652 "$ref": "#/definitions/nonBodyParameter"
20653 }
20654 ]
20655 },
20656 "schema": {
20657 "type": "object",
20658 "description": "A deterministic version of a JSON Schema object.",
20659 "patternProperties": {
20660 "^x-": {
20661 "$ref": "#/definitions/vendorExtension"
20662 }
20663 },
20664 "properties": {
20665 "$ref": {
20666 "type": "string"
20667 },
20668 "format": {
20669 "type": "string"
20670 },
20671 "title": {
20672 "$ref": "http://json-schema.org/draft-04/schema#/properties/title"
20673 },
20674 "description": {
20675 "$ref": "http://json-schema.org/draft-04/schema#/properties/description"
20676 },
20677 "default": {
20678 "$ref": "http://json-schema.org/draft-04/schema#/properties/default"
20679 },
20680 "multipleOf": {
20681 "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"
20682 },
20683 "maximum": {
20684 "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"
20685 },
20686 "exclusiveMaximum": {
20687 "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
20688 },
20689 "minimum": {
20690 "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"
20691 },
20692 "exclusiveMinimum": {
20693 "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
20694 },
20695 "maxLength": {
20696 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
20697 },
20698 "minLength": {
20699 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
20700 },
20701 "pattern": {
20702 "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"
20703 },
20704 "maxItems": {
20705 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
20706 },
20707 "minItems": {
20708 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
20709 },
20710 "uniqueItems": {
20711 "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
20712 },
20713 "maxProperties": {
20714 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
20715 },
20716 "minProperties": {
20717 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
20718 },
20719 "required": {
20720 "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"
20721 },
20722 "enum": {
20723 "$ref": "http://json-schema.org/draft-04/schema#/properties/enum"
20724 },
20725 "additionalProperties": {
20726 "anyOf": [
20727 {
20728 "$ref": "#/definitions/schema"
20729 },
20730 {
20731 "type": "boolean"
20732 }
20733 ],
20734 "default": {}
20735 },
20736 "type": {
20737 "$ref": "http://json-schema.org/draft-04/schema#/properties/type"
20738 },
20739 "items": {
20740 "anyOf": [
20741 {
20742 "$ref": "#/definitions/schema"
20743 },
20744 {
20745 "type": "array",
20746 "minItems": 1,
20747 "items": {
20748 "$ref": "#/definitions/schema"
20749 }
20750 }
20751 ],
20752 "default": {}
20753 },
20754 "allOf": {
20755 "type": "array",
20756 "minItems": 1,
20757 "items": {
20758 "$ref": "#/definitions/schema"
20759 }
20760 },
20761 "properties": {
20762 "type": "object",
20763 "additionalProperties": {
20764 "$ref": "#/definitions/schema"
20765 },
20766 "default": {}
20767 },
20768 "discriminator": {
20769 "type": "string"
20770 },
20771 "readOnly": {
20772 "type": "boolean",
20773 "default": false
20774 },
20775 "xml": {
20776 "$ref": "#/definitions/xml"
20777 },
20778 "externalDocs": {
20779 "$ref": "#/definitions/externalDocs"
20780 },
20781 "example": {}
20782 },
20783 "additionalProperties": false
20784 },
20785 "fileSchema": {
20786 "type": "object",
20787 "description": "A deterministic version of a JSON Schema object.",
20788 "patternProperties": {
20789 "^x-": {
20790 "$ref": "#/definitions/vendorExtension"
20791 }
20792 },
20793 "required": [
20794 "type"
20795 ],
20796 "properties": {
20797 "format": {
20798 "type": "string"
20799 },
20800 "title": {
20801 "$ref": "http://json-schema.org/draft-04/schema#/properties/title"
20802 },
20803 "description": {
20804 "$ref": "http://json-schema.org/draft-04/schema#/properties/description"
20805 },
20806 "default": {
20807 "$ref": "http://json-schema.org/draft-04/schema#/properties/default"
20808 },
20809 "required": {
20810 "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"
20811 },
20812 "type": {
20813 "type": "string",
20814 "enum": [
20815 "file"
20816 ]
20817 },
20818 "readOnly": {
20819 "type": "boolean",
20820 "default": false
20821 },
20822 "externalDocs": {
20823 "$ref": "#/definitions/externalDocs"
20824 },
20825 "example": {}
20826 },
20827 "additionalProperties": false
20828 },
20829 "primitivesItems": {
20830 "type": "object",
20831 "additionalProperties": false,
20832 "properties": {
20833 "type": {
20834 "type": "string",
20835 "enum": [
20836 "string",
20837 "number",
20838 "integer",
20839 "boolean",
20840 "array"
20841 ]
20842 },
20843 "format": {
20844 "type": "string"
20845 },
20846 "items": {
20847 "$ref": "#/definitions/primitivesItems"
20848 },
20849 "collectionFormat": {
20850 "$ref": "#/definitions/collectionFormat"
20851 },
20852 "default": {
20853 "$ref": "#/definitions/default"
20854 },
20855 "maximum": {
20856 "$ref": "#/definitions/maximum"
20857 },
20858 "exclusiveMaximum": {
20859 "$ref": "#/definitions/exclusiveMaximum"
20860 },
20861 "minimum": {
20862 "$ref": "#/definitions/minimum"
20863 },
20864 "exclusiveMinimum": {
20865 "$ref": "#/definitions/exclusiveMinimum"
20866 },
20867 "maxLength": {
20868 "$ref": "#/definitions/maxLength"
20869 },
20870 "minLength": {
20871 "$ref": "#/definitions/minLength"
20872 },
20873 "pattern": {
20874 "$ref": "#/definitions/pattern"
20875 },
20876 "maxItems": {
20877 "$ref": "#/definitions/maxItems"
20878 },
20879 "minItems": {
20880 "$ref": "#/definitions/minItems"
20881 },
20882 "uniqueItems": {
20883 "$ref": "#/definitions/uniqueItems"
20884 },
20885 "enum": {
20886 "$ref": "#/definitions/enum"
20887 },
20888 "multipleOf": {
20889 "$ref": "#/definitions/multipleOf"
20890 }
20891 },
20892 "patternProperties": {
20893 "^x-": {
20894 "$ref": "#/definitions/vendorExtension"
20895 }
20896 }
20897 },
20898 "security": {
20899 "type": "array",
20900 "items": {
20901 "$ref": "#/definitions/securityRequirement"
20902 },
20903 "uniqueItems": true
20904 },
20905 "securityRequirement": {
20906 "type": "object",
20907 "additionalProperties": {
20908 "type": "array",
20909 "items": {
20910 "type": "string"
20911 },
20912 "uniqueItems": true
20913 }
20914 },
20915 "xml": {
20916 "type": "object",
20917 "additionalProperties": false,
20918 "properties": {
20919 "name": {
20920 "type": "string"
20921 },
20922 "namespace": {
20923 "type": "string"
20924 },
20925 "prefix": {
20926 "type": "string"
20927 },
20928 "attribute": {
20929 "type": "boolean",
20930 "default": false
20931 },
20932 "wrapped": {
20933 "type": "boolean",
20934 "default": false
20935 }
20936 },
20937 "patternProperties": {
20938 "^x-": {
20939 "$ref": "#/definitions/vendorExtension"
20940 }
20941 }
20942 },
20943 "tag": {
20944 "type": "object",
20945 "additionalProperties": false,
20946 "required": [
20947 "name"
20948 ],
20949 "properties": {
20950 "name": {
20951 "type": "string"
20952 },
20953 "description": {
20954 "type": "string"
20955 },
20956 "externalDocs": {
20957 "$ref": "#/definitions/externalDocs"
20958 }
20959 },
20960 "patternProperties": {
20961 "^x-": {
20962 "$ref": "#/definitions/vendorExtension"
20963 }
20964 }
20965 },
20966 "securityDefinitions": {
20967 "type": "object",
20968 "additionalProperties": {
20969 "oneOf": [
20970 {
20971 "$ref": "#/definitions/basicAuthenticationSecurity"
20972 },
20973 {
20974 "$ref": "#/definitions/apiKeySecurity"
20975 },
20976 {
20977 "$ref": "#/definitions/oauth2ImplicitSecurity"
20978 },
20979 {
20980 "$ref": "#/definitions/oauth2PasswordSecurity"
20981 },
20982 {
20983 "$ref": "#/definitions/oauth2ApplicationSecurity"
20984 },
20985 {
20986 "$ref": "#/definitions/oauth2AccessCodeSecurity"
20987 }
20988 ]
20989 }
20990 },
20991 "basicAuthenticationSecurity": {
20992 "type": "object",
20993 "additionalProperties": false,
20994 "required": [
20995 "type"
20996 ],
20997 "properties": {
20998 "type": {
20999 "type": "string",
21000 "enum": [
21001 "basic"
21002 ]
21003 },
21004 "description": {
21005 "type": "string"
21006 }
21007 },
21008 "patternProperties": {
21009 "^x-": {
21010 "$ref": "#/definitions/vendorExtension"
21011 }
21012 }
21013 },
21014 "apiKeySecurity": {
21015 "type": "object",
21016 "additionalProperties": false,
21017 "required": [
21018 "type",
21019 "name",
21020 "in"
21021 ],
21022 "properties": {
21023 "type": {
21024 "type": "string",
21025 "enum": [
21026 "apiKey"
21027 ]
21028 },
21029 "name": {
21030 "type": "string"
21031 },
21032 "in": {
21033 "type": "string",
21034 "enum": [
21035 "header",
21036 "query"
21037 ]
21038 },
21039 "description": {
21040 "type": "string"
21041 }
21042 },
21043 "patternProperties": {
21044 "^x-": {
21045 "$ref": "#/definitions/vendorExtension"
21046 }
21047 }
21048 },
21049 "oauth2ImplicitSecurity": {
21050 "type": "object",
21051 "additionalProperties": false,
21052 "required": [
21053 "type",
21054 "flow",
21055 "authorizationUrl"
21056 ],
21057 "properties": {
21058 "type": {
21059 "type": "string",
21060 "enum": [
21061 "oauth2"
21062 ]
21063 },
21064 "flow": {
21065 "type": "string",
21066 "enum": [
21067 "implicit"
21068 ]
21069 },
21070 "scopes": {
21071 "$ref": "#/definitions/oauth2Scopes"
21072 },
21073 "authorizationUrl": {
21074 "type": "string",
21075 "format": "uri"
21076 },
21077 "description": {
21078 "type": "string"
21079 }
21080 },
21081 "patternProperties": {
21082 "^x-": {
21083 "$ref": "#/definitions/vendorExtension"
21084 }
21085 }
21086 },
21087 "oauth2PasswordSecurity": {
21088 "type": "object",
21089 "additionalProperties": false,
21090 "required": [
21091 "type",
21092 "flow",
21093 "tokenUrl"
21094 ],
21095 "properties": {
21096 "type": {
21097 "type": "string",
21098 "enum": [
21099 "oauth2"
21100 ]
21101 },
21102 "flow": {
21103 "type": "string",
21104 "enum": [
21105 "password"
21106 ]
21107 },
21108 "scopes": {
21109 "$ref": "#/definitions/oauth2Scopes"
21110 },
21111 "tokenUrl": {
21112 "type": "string",
21113 "format": "uri"
21114 },
21115 "description": {
21116 "type": "string"
21117 }
21118 },
21119 "patternProperties": {
21120 "^x-": {
21121 "$ref": "#/definitions/vendorExtension"
21122 }
21123 }
21124 },
21125 "oauth2ApplicationSecurity": {
21126 "type": "object",
21127 "additionalProperties": false,
21128 "required": [
21129 "type",
21130 "flow",
21131 "tokenUrl"
21132 ],
21133 "properties": {
21134 "type": {
21135 "type": "string",
21136 "enum": [
21137 "oauth2"
21138 ]
21139 },
21140 "flow": {
21141 "type": "string",
21142 "enum": [
21143 "application"
21144 ]
21145 },
21146 "scopes": {
21147 "$ref": "#/definitions/oauth2Scopes"
21148 },
21149 "tokenUrl": {
21150 "type": "string",
21151 "format": "uri"
21152 },
21153 "description": {
21154 "type": "string"
21155 }
21156 },
21157 "patternProperties": {
21158 "^x-": {
21159 "$ref": "#/definitions/vendorExtension"
21160 }
21161 }
21162 },
21163 "oauth2AccessCodeSecurity": {
21164 "type": "object",
21165 "additionalProperties": false,
21166 "required": [
21167 "type",
21168 "flow",
21169 "authorizationUrl",
21170 "tokenUrl"
21171 ],
21172 "properties": {
21173 "type": {
21174 "type": "string",
21175 "enum": [
21176 "oauth2"
21177 ]
21178 },
21179 "flow": {
21180 "type": "string",
21181 "enum": [
21182 "accessCode"
21183 ]
21184 },
21185 "scopes": {
21186 "$ref": "#/definitions/oauth2Scopes"
21187 },
21188 "authorizationUrl": {
21189 "type": "string",
21190 "format": "uri"
21191 },
21192 "tokenUrl": {
21193 "type": "string",
21194 "format": "uri"
21195 },
21196 "description": {
21197 "type": "string"
21198 }
21199 },
21200 "patternProperties": {
21201 "^x-": {
21202 "$ref": "#/definitions/vendorExtension"
21203 }
21204 }
21205 },
21206 "oauth2Scopes": {
21207 "type": "object",
21208 "additionalProperties": {
21209 "type": "string"
21210 }
21211 },
21212 "mediaTypeList": {
21213 "type": "array",
21214 "items": {
21215 "$ref": "#/definitions/mimeType"
21216 },
21217 "uniqueItems": true
21218 },
21219 "parametersList": {
21220 "type": "array",
21221 "description": "The parameters needed to send a valid API call.",
21222 "additionalItems": false,
21223 "items": {
21224 "oneOf": [
21225 {
21226 "$ref": "#/definitions/parameter"
21227 },
21228 {
21229 "$ref": "#/definitions/jsonReference"
21230 }
21231 ]
21232 },
21233 "uniqueItems": true
21234 },
21235 "schemesList": {
21236 "type": "array",
21237 "description": "The transfer protocol of the API.",
21238 "items": {
21239 "type": "string",
21240 "enum": [
21241 "http",
21242 "https",
21243 "ws",
21244 "wss"
21245 ]
21246 },
21247 "uniqueItems": true
21248 },
21249 "collectionFormat": {
21250 "type": "string",
21251 "enum": [
21252 "csv",
21253 "ssv",
21254 "tsv",
21255 "pipes"
21256 ],
21257 "default": "csv"
21258 },
21259 "collectionFormatWithMulti": {
21260 "type": "string",
21261 "enum": [
21262 "csv",
21263 "ssv",
21264 "tsv",
21265 "pipes",
21266 "multi"
21267 ],
21268 "default": "csv"
21269 },
21270 "title": {
21271 "$ref": "http://json-schema.org/draft-04/schema#/properties/title"
21272 },
21273 "description": {
21274 "$ref": "http://json-schema.org/draft-04/schema#/properties/description"
21275 },
21276 "default": {
21277 "$ref": "http://json-schema.org/draft-04/schema#/properties/default"
21278 },
21279 "multipleOf": {
21280 "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"
21281 },
21282 "maximum": {
21283 "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"
21284 },
21285 "exclusiveMaximum": {
21286 "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
21287 },
21288 "minimum": {
21289 "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"
21290 },
21291 "exclusiveMinimum": {
21292 "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
21293 },
21294 "maxLength": {
21295 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
21296 },
21297 "minLength": {
21298 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
21299 },
21300 "pattern": {
21301 "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"
21302 },
21303 "maxItems": {
21304 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
21305 },
21306 "minItems": {
21307 "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
21308 },
21309 "uniqueItems": {
21310 "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
21311 },
21312 "enum": {
21313 "$ref": "http://json-schema.org/draft-04/schema#/properties/enum"
21314 },
21315 "jsonReference": {
21316 "type": "object",
21317 "required": [
21318 "$ref"
21319 ],
21320 "additionalProperties": false,
21321 "properties": {
21322 "$ref": {
21323 "type": "string"
21324 }
21325 }
21326 }
21327 }
21328}
21329},{}],146:[function(require,module,exports){
21330(function (setImmediate,clearImmediate){
21331var nextTick = require('process/browser.js').nextTick;
21332var apply = Function.prototype.apply;
21333var slice = Array.prototype.slice;
21334var immediateIds = {};
21335var nextImmediateId = 0;
21336
21337// DOM APIs, for completeness
21338
21339exports.setTimeout = function() {
21340 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
21341};
21342exports.setInterval = function() {
21343 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
21344};
21345exports.clearTimeout =
21346exports.clearInterval = function(timeout) { timeout.close(); };
21347
21348function Timeout(id, clearFn) {
21349 this._id = id;
21350 this._clearFn = clearFn;
21351}
21352Timeout.prototype.unref = Timeout.prototype.ref = function() {};
21353Timeout.prototype.close = function() {
21354 this._clearFn.call(window, this._id);
21355};
21356
21357// Does not start the time, just sets up the members needed.
21358exports.enroll = function(item, msecs) {
21359 clearTimeout(item._idleTimeoutId);
21360 item._idleTimeout = msecs;
21361};
21362
21363exports.unenroll = function(item) {
21364 clearTimeout(item._idleTimeoutId);
21365 item._idleTimeout = -1;
21366};
21367
21368exports._unrefActive = exports.active = function(item) {
21369 clearTimeout(item._idleTimeoutId);
21370
21371 var msecs = item._idleTimeout;
21372 if (msecs >= 0) {
21373 item._idleTimeoutId = setTimeout(function onTimeout() {
21374 if (item._onTimeout)
21375 item._onTimeout();
21376 }, msecs);
21377 }
21378};
21379
21380// That's not how node.js implements it but the exposed api is the same.
21381exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
21382 var id = nextImmediateId++;
21383 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
21384
21385 immediateIds[id] = true;
21386
21387 nextTick(function onNextTick() {
21388 if (immediateIds[id]) {
21389 // fn.call() is faster so we optimize for the common use-case
21390 // @see http://jsperf.com/call-apply-segu
21391 if (args) {
21392 fn.apply(null, args);
21393 } else {
21394 fn.call(null);
21395 }
21396 // Prevent ids from leaking
21397 exports.clearImmediate(id);
21398 }
21399 });
21400
21401 return id;
21402};
21403
21404exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
21405 delete immediateIds[id];
21406};
21407}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
21408
21409},{"process/browser.js":125,"timers":146}],147:[function(require,module,exports){
21410var Buffer = require('buffer').Buffer
21411
21412module.exports = function (buf) {
21413 // If the buffer is backed by a Uint8Array, a faster version will work
21414 if (buf instanceof Uint8Array) {
21415 // If the buffer isn't a subarray, return the underlying ArrayBuffer
21416 if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
21417 return buf.buffer
21418 } else if (typeof buf.buffer.slice === 'function') {
21419 // Otherwise we need to get a proper copy
21420 return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
21421 }
21422 }
21423
21424 if (Buffer.isBuffer(buf)) {
21425 // This is the slow version that will work with any Buffer
21426 // implementation (even in old browsers)
21427 var arrayCopy = new Uint8Array(buf.length)
21428 var len = buf.length
21429 for (var i = 0; i < len; i++) {
21430 arrayCopy[i] = buf[i]
21431 }
21432 return arrayCopy.buffer
21433 } else {
21434 throw new Error('Argument must be a Buffer')
21435 }
21436}
21437
21438},{"buffer":9}],148:[function(require,module,exports){
21439// Copyright Joyent, Inc. and other Node contributors.
21440//
21441// Permission is hereby granted, free of charge, to any person obtaining a
21442// copy of this software and associated documentation files (the
21443// "Software"), to deal in the Software without restriction, including
21444// without limitation the rights to use, copy, modify, merge, publish,
21445// distribute, sublicense, and/or sell copies of the Software, and to permit
21446// persons to whom the Software is furnished to do so, subject to the
21447// following conditions:
21448//
21449// The above copyright notice and this permission notice shall be included
21450// in all copies or substantial portions of the Software.
21451//
21452// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21453// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21454// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21455// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21456// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21457// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21458// USE OR OTHER DEALINGS IN THE SOFTWARE.
21459
21460'use strict';
21461
21462var punycode = require('punycode');
21463var util = require('./util');
21464
21465exports.parse = urlParse;
21466exports.resolve = urlResolve;
21467exports.resolveObject = urlResolveObject;
21468exports.format = urlFormat;
21469
21470exports.Url = Url;
21471
21472function Url() {
21473 this.protocol = null;
21474 this.slashes = null;
21475 this.auth = null;
21476 this.host = null;
21477 this.port = null;
21478 this.hostname = null;
21479 this.hash = null;
21480 this.search = null;
21481 this.query = null;
21482 this.pathname = null;
21483 this.path = null;
21484 this.href = null;
21485}
21486
21487// Reference: RFC 3986, RFC 1808, RFC 2396
21488
21489// define these here so at least they only have to be
21490// compiled once on the first module load.
21491var protocolPattern = /^([a-z0-9.+-]+:)/i,
21492 portPattern = /:[0-9]*$/,
21493
21494 // Special case for a simple path URL
21495 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
21496
21497 // RFC 2396: characters reserved for delimiting URLs.
21498 // We actually just auto-escape these.
21499 delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
21500
21501 // RFC 2396: characters not allowed for various reasons.
21502 unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
21503
21504 // Allowed by RFCs, but cause of XSS attacks. Always escape these.
21505 autoEscape = ['\''].concat(unwise),
21506 // Characters that are never ever allowed in a hostname.
21507 // Note that any invalid chars are also handled, but these
21508 // are the ones that are *expected* to be seen, so we fast-path
21509 // them.
21510 nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
21511 hostEndingChars = ['/', '?', '#'],
21512 hostnameMaxLen = 255,
21513 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
21514 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
21515 // protocols that can allow "unsafe" and "unwise" chars.
21516 unsafeProtocol = {
21517 'javascript': true,
21518 'javascript:': true
21519 },
21520 // protocols that never have a hostname.
21521 hostlessProtocol = {
21522 'javascript': true,
21523 'javascript:': true
21524 },
21525 // protocols that always contain a // bit.
21526 slashedProtocol = {
21527 'http': true,
21528 'https': true,
21529 'ftp': true,
21530 'gopher': true,
21531 'file': true,
21532 'http:': true,
21533 'https:': true,
21534 'ftp:': true,
21535 'gopher:': true,
21536 'file:': true
21537 },
21538 querystring = require('querystring');
21539
21540function urlParse(url, parseQueryString, slashesDenoteHost) {
21541 if (url && util.isObject(url) && url instanceof Url) return url;
21542
21543 var u = new Url;
21544 u.parse(url, parseQueryString, slashesDenoteHost);
21545 return u;
21546}
21547
21548Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
21549 if (!util.isString(url)) {
21550 throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
21551 }
21552
21553 // Copy chrome, IE, opera backslash-handling behavior.
21554 // Back slashes before the query string get converted to forward slashes
21555 // See: https://code.google.com/p/chromium/issues/detail?id=25916
21556 var queryIndex = url.indexOf('?'),
21557 splitter =
21558 (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
21559 uSplit = url.split(splitter),
21560 slashRegex = /\\/g;
21561 uSplit[0] = uSplit[0].replace(slashRegex, '/');
21562 url = uSplit.join(splitter);
21563
21564 var rest = url;
21565
21566 // trim before proceeding.
21567 // This is to support parse stuff like " http://foo.com \n"
21568 rest = rest.trim();
21569
21570 if (!slashesDenoteHost && url.split('#').length === 1) {
21571 // Try fast path regexp
21572 var simplePath = simplePathPattern.exec(rest);
21573 if (simplePath) {
21574 this.path = rest;
21575 this.href = rest;
21576 this.pathname = simplePath[1];
21577 if (simplePath[2]) {
21578 this.search = simplePath[2];
21579 if (parseQueryString) {
21580 this.query = querystring.parse(this.search.substr(1));
21581 } else {
21582 this.query = this.search.substr(1);
21583 }
21584 } else if (parseQueryString) {
21585 this.search = '';
21586 this.query = {};
21587 }
21588 return this;
21589 }
21590 }
21591
21592 var proto = protocolPattern.exec(rest);
21593 if (proto) {
21594 proto = proto[0];
21595 var lowerProto = proto.toLowerCase();
21596 this.protocol = lowerProto;
21597 rest = rest.substr(proto.length);
21598 }
21599
21600 // figure out if it's got a host
21601 // user@server is *always* interpreted as a hostname, and url
21602 // resolution will treat //foo/bar as host=foo,path=bar because that's
21603 // how the browser resolves relative URLs.
21604 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
21605 var slashes = rest.substr(0, 2) === '//';
21606 if (slashes && !(proto && hostlessProtocol[proto])) {
21607 rest = rest.substr(2);
21608 this.slashes = true;
21609 }
21610 }
21611
21612 if (!hostlessProtocol[proto] &&
21613 (slashes || (proto && !slashedProtocol[proto]))) {
21614
21615 // there's a hostname.
21616 // the first instance of /, ?, ;, or # ends the host.
21617 //
21618 // If there is an @ in the hostname, then non-host chars *are* allowed
21619 // to the left of the last @ sign, unless some host-ending character
21620 // comes *before* the @-sign.
21621 // URLs are obnoxious.
21622 //
21623 // ex:
21624 // http://a@b@c/ => user:a@b host:c
21625 // http://a@b?@c => user:a host:c path:/?@c
21626
21627 // v0.12 TODO(isaacs): This is not quite how Chrome does things.
21628 // Review our test case against browsers more comprehensively.
21629
21630 // find the first instance of any hostEndingChars
21631 var hostEnd = -1;
21632 for (var i = 0; i < hostEndingChars.length; i++) {
21633 var hec = rest.indexOf(hostEndingChars[i]);
21634 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
21635 hostEnd = hec;
21636 }
21637
21638 // at this point, either we have an explicit point where the
21639 // auth portion cannot go past, or the last @ char is the decider.
21640 var auth, atSign;
21641 if (hostEnd === -1) {
21642 // atSign can be anywhere.
21643 atSign = rest.lastIndexOf('@');
21644 } else {
21645 // atSign must be in auth portion.
21646 // http://a@b/c@d => host:b auth:a path:/c@d
21647 atSign = rest.lastIndexOf('@', hostEnd);
21648 }
21649
21650 // Now we have a portion which is definitely the auth.
21651 // Pull that off.
21652 if (atSign !== -1) {
21653 auth = rest.slice(0, atSign);
21654 rest = rest.slice(atSign + 1);
21655 this.auth = decodeURIComponent(auth);
21656 }
21657
21658 // the host is the remaining to the left of the first non-host char
21659 hostEnd = -1;
21660 for (var i = 0; i < nonHostChars.length; i++) {
21661 var hec = rest.indexOf(nonHostChars[i]);
21662 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
21663 hostEnd = hec;
21664 }
21665 // if we still have not hit it, then the entire thing is a host.
21666 if (hostEnd === -1)
21667 hostEnd = rest.length;
21668
21669 this.host = rest.slice(0, hostEnd);
21670 rest = rest.slice(hostEnd);
21671
21672 // pull out port.
21673 this.parseHost();
21674
21675 // we've indicated that there is a hostname,
21676 // so even if it's empty, it has to be present.
21677 this.hostname = this.hostname || '';
21678
21679 // if hostname begins with [ and ends with ]
21680 // assume that it's an IPv6 address.
21681 var ipv6Hostname = this.hostname[0] === '[' &&
21682 this.hostname[this.hostname.length - 1] === ']';
21683
21684 // validate a little.
21685 if (!ipv6Hostname) {
21686 var hostparts = this.hostname.split(/\./);
21687 for (var i = 0, l = hostparts.length; i < l; i++) {
21688 var part = hostparts[i];
21689 if (!part) continue;
21690 if (!part.match(hostnamePartPattern)) {
21691 var newpart = '';
21692 for (var j = 0, k = part.length; j < k; j++) {
21693 if (part.charCodeAt(j) > 127) {
21694 // we replace non-ASCII char with a temporary placeholder
21695 // we need this to make sure size of hostname is not
21696 // broken by replacing non-ASCII by nothing
21697 newpart += 'x';
21698 } else {
21699 newpart += part[j];
21700 }
21701 }
21702 // we test again with ASCII char only
21703 if (!newpart.match(hostnamePartPattern)) {
21704 var validParts = hostparts.slice(0, i);
21705 var notHost = hostparts.slice(i + 1);
21706 var bit = part.match(hostnamePartStart);
21707 if (bit) {
21708 validParts.push(bit[1]);
21709 notHost.unshift(bit[2]);
21710 }
21711 if (notHost.length) {
21712 rest = '/' + notHost.join('.') + rest;
21713 }
21714 this.hostname = validParts.join('.');
21715 break;
21716 }
21717 }
21718 }
21719 }
21720
21721 if (this.hostname.length > hostnameMaxLen) {
21722 this.hostname = '';
21723 } else {
21724 // hostnames are always lower case.
21725 this.hostname = this.hostname.toLowerCase();
21726 }
21727
21728 if (!ipv6Hostname) {
21729 // IDNA Support: Returns a punycoded representation of "domain".
21730 // It only converts parts of the domain name that
21731 // have non-ASCII characters, i.e. it doesn't matter if
21732 // you call it with a domain that already is ASCII-only.
21733 this.hostname = punycode.toASCII(this.hostname);
21734 }
21735
21736 var p = this.port ? ':' + this.port : '';
21737 var h = this.hostname || '';
21738 this.host = h + p;
21739 this.href += this.host;
21740
21741 // strip [ and ] from the hostname
21742 // the host field still retains them, though
21743 if (ipv6Hostname) {
21744 this.hostname = this.hostname.substr(1, this.hostname.length - 2);
21745 if (rest[0] !== '/') {
21746 rest = '/' + rest;
21747 }
21748 }
21749 }
21750
21751 // now rest is set to the post-host stuff.
21752 // chop off any delim chars.
21753 if (!unsafeProtocol[lowerProto]) {
21754
21755 // First, make 100% sure that any "autoEscape" chars get
21756 // escaped, even if encodeURIComponent doesn't think they
21757 // need to be.
21758 for (var i = 0, l = autoEscape.length; i < l; i++) {
21759 var ae = autoEscape[i];
21760 if (rest.indexOf(ae) === -1)
21761 continue;
21762 var esc = encodeURIComponent(ae);
21763 if (esc === ae) {
21764 esc = escape(ae);
21765 }
21766 rest = rest.split(ae).join(esc);
21767 }
21768 }
21769
21770
21771 // chop off from the tail first.
21772 var hash = rest.indexOf('#');
21773 if (hash !== -1) {
21774 // got a fragment string.
21775 this.hash = rest.substr(hash);
21776 rest = rest.slice(0, hash);
21777 }
21778 var qm = rest.indexOf('?');
21779 if (qm !== -1) {
21780 this.search = rest.substr(qm);
21781 this.query = rest.substr(qm + 1);
21782 if (parseQueryString) {
21783 this.query = querystring.parse(this.query);
21784 }
21785 rest = rest.slice(0, qm);
21786 } else if (parseQueryString) {
21787 // no query string, but parseQueryString still requested
21788 this.search = '';
21789 this.query = {};
21790 }
21791 if (rest) this.pathname = rest;
21792 if (slashedProtocol[lowerProto] &&
21793 this.hostname && !this.pathname) {
21794 this.pathname = '/';
21795 }
21796
21797 //to support http.request
21798 if (this.pathname || this.search) {
21799 var p = this.pathname || '';
21800 var s = this.search || '';
21801 this.path = p + s;
21802 }
21803
21804 // finally, reconstruct the href based on what has been validated.
21805 this.href = this.format();
21806 return this;
21807};
21808
21809// format a parsed object into a url string
21810function urlFormat(obj) {
21811 // ensure it's an object, and not a string url.
21812 // If it's an obj, this is a no-op.
21813 // this way, you can call url_format() on strings
21814 // to clean up potentially wonky urls.
21815 if (util.isString(obj)) obj = urlParse(obj);
21816 if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
21817 return obj.format();
21818}
21819
21820Url.prototype.format = function() {
21821 var auth = this.auth || '';
21822 if (auth) {
21823 auth = encodeURIComponent(auth);
21824 auth = auth.replace(/%3A/i, ':');
21825 auth += '@';
21826 }
21827
21828 var protocol = this.protocol || '',
21829 pathname = this.pathname || '',
21830 hash = this.hash || '',
21831 host = false,
21832 query = '';
21833
21834 if (this.host) {
21835 host = auth + this.host;
21836 } else if (this.hostname) {
21837 host = auth + (this.hostname.indexOf(':') === -1 ?
21838 this.hostname :
21839 '[' + this.hostname + ']');
21840 if (this.port) {
21841 host += ':' + this.port;
21842 }
21843 }
21844
21845 if (this.query &&
21846 util.isObject(this.query) &&
21847 Object.keys(this.query).length) {
21848 query = querystring.stringify(this.query);
21849 }
21850
21851 var search = this.search || (query && ('?' + query)) || '';
21852
21853 if (protocol && protocol.substr(-1) !== ':') protocol += ':';
21854
21855 // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
21856 // unless they had them to begin with.
21857 if (this.slashes ||
21858 (!protocol || slashedProtocol[protocol]) && host !== false) {
21859 host = '//' + (host || '');
21860 if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
21861 } else if (!host) {
21862 host = '';
21863 }
21864
21865 if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
21866 if (search && search.charAt(0) !== '?') search = '?' + search;
21867
21868 pathname = pathname.replace(/[?#]/g, function(match) {
21869 return encodeURIComponent(match);
21870 });
21871 search = search.replace('#', '%23');
21872
21873 return protocol + host + pathname + search + hash;
21874};
21875
21876function urlResolve(source, relative) {
21877 return urlParse(source, false, true).resolve(relative);
21878}
21879
21880Url.prototype.resolve = function(relative) {
21881 return this.resolveObject(urlParse(relative, false, true)).format();
21882};
21883
21884function urlResolveObject(source, relative) {
21885 if (!source) return relative;
21886 return urlParse(source, false, true).resolveObject(relative);
21887}
21888
21889Url.prototype.resolveObject = function(relative) {
21890 if (util.isString(relative)) {
21891 var rel = new Url();
21892 rel.parse(relative, false, true);
21893 relative = rel;
21894 }
21895
21896 var result = new Url();
21897 var tkeys = Object.keys(this);
21898 for (var tk = 0; tk < tkeys.length; tk++) {
21899 var tkey = tkeys[tk];
21900 result[tkey] = this[tkey];
21901 }
21902
21903 // hash is always overridden, no matter what.
21904 // even href="" will remove it.
21905 result.hash = relative.hash;
21906
21907 // if the relative url is empty, then there's nothing left to do here.
21908 if (relative.href === '') {
21909 result.href = result.format();
21910 return result;
21911 }
21912
21913 // hrefs like //foo/bar always cut to the protocol.
21914 if (relative.slashes && !relative.protocol) {
21915 // take everything except the protocol from relative
21916 var rkeys = Object.keys(relative);
21917 for (var rk = 0; rk < rkeys.length; rk++) {
21918 var rkey = rkeys[rk];
21919 if (rkey !== 'protocol')
21920 result[rkey] = relative[rkey];
21921 }
21922
21923 //urlParse appends trailing / to urls like http://www.example.com
21924 if (slashedProtocol[result.protocol] &&
21925 result.hostname && !result.pathname) {
21926 result.path = result.pathname = '/';
21927 }
21928
21929 result.href = result.format();
21930 return result;
21931 }
21932
21933 if (relative.protocol && relative.protocol !== result.protocol) {
21934 // if it's a known url protocol, then changing
21935 // the protocol does weird things
21936 // first, if it's not file:, then we MUST have a host,
21937 // and if there was a path
21938 // to begin with, then we MUST have a path.
21939 // if it is file:, then the host is dropped,
21940 // because that's known to be hostless.
21941 // anything else is assumed to be absolute.
21942 if (!slashedProtocol[relative.protocol]) {
21943 var keys = Object.keys(relative);
21944 for (var v = 0; v < keys.length; v++) {
21945 var k = keys[v];
21946 result[k] = relative[k];
21947 }
21948 result.href = result.format();
21949 return result;
21950 }
21951
21952 result.protocol = relative.protocol;
21953 if (!relative.host && !hostlessProtocol[relative.protocol]) {
21954 var relPath = (relative.pathname || '').split('/');
21955 while (relPath.length && !(relative.host = relPath.shift()));
21956 if (!relative.host) relative.host = '';
21957 if (!relative.hostname) relative.hostname = '';
21958 if (relPath[0] !== '') relPath.unshift('');
21959 if (relPath.length < 2) relPath.unshift('');
21960 result.pathname = relPath.join('/');
21961 } else {
21962 result.pathname = relative.pathname;
21963 }
21964 result.search = relative.search;
21965 result.query = relative.query;
21966 result.host = relative.host || '';
21967 result.auth = relative.auth;
21968 result.hostname = relative.hostname || relative.host;
21969 result.port = relative.port;
21970 // to support http.request
21971 if (result.pathname || result.search) {
21972 var p = result.pathname || '';
21973 var s = result.search || '';
21974 result.path = p + s;
21975 }
21976 result.slashes = result.slashes || relative.slashes;
21977 result.href = result.format();
21978 return result;
21979 }
21980
21981 var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
21982 isRelAbs = (
21983 relative.host ||
21984 relative.pathname && relative.pathname.charAt(0) === '/'
21985 ),
21986 mustEndAbs = (isRelAbs || isSourceAbs ||
21987 (result.host && relative.pathname)),
21988 removeAllDots = mustEndAbs,
21989 srcPath = result.pathname && result.pathname.split('/') || [],
21990 relPath = relative.pathname && relative.pathname.split('/') || [],
21991 psychotic = result.protocol && !slashedProtocol[result.protocol];
21992
21993 // if the url is a non-slashed url, then relative
21994 // links like ../.. should be able
21995 // to crawl up to the hostname, as well. This is strange.
21996 // result.protocol has already been set by now.
21997 // Later on, put the first path part into the host field.
21998 if (psychotic) {
21999 result.hostname = '';
22000 result.port = null;
22001 if (result.host) {
22002 if (srcPath[0] === '') srcPath[0] = result.host;
22003 else srcPath.unshift(result.host);
22004 }
22005 result.host = '';
22006 if (relative.protocol) {
22007 relative.hostname = null;
22008 relative.port = null;
22009 if (relative.host) {
22010 if (relPath[0] === '') relPath[0] = relative.host;
22011 else relPath.unshift(relative.host);
22012 }
22013 relative.host = null;
22014 }
22015 mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
22016 }
22017
22018 if (isRelAbs) {
22019 // it's absolute.
22020 result.host = (relative.host || relative.host === '') ?
22021 relative.host : result.host;
22022 result.hostname = (relative.hostname || relative.hostname === '') ?
22023 relative.hostname : result.hostname;
22024 result.search = relative.search;
22025 result.query = relative.query;
22026 srcPath = relPath;
22027 // fall through to the dot-handling below.
22028 } else if (relPath.length) {
22029 // it's relative
22030 // throw away the existing file, and take the new path instead.
22031 if (!srcPath) srcPath = [];
22032 srcPath.pop();
22033 srcPath = srcPath.concat(relPath);
22034 result.search = relative.search;
22035 result.query = relative.query;
22036 } else if (!util.isNullOrUndefined(relative.search)) {
22037 // just pull out the search.
22038 // like href='?foo'.
22039 // Put this after the other two cases because it simplifies the booleans
22040 if (psychotic) {
22041 result.hostname = result.host = srcPath.shift();
22042 //occationaly the auth can get stuck only in host
22043 //this especially happens in cases like
22044 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
22045 var authInHost = result.host && result.host.indexOf('@') > 0 ?
22046 result.host.split('@') : false;
22047 if (authInHost) {
22048 result.auth = authInHost.shift();
22049 result.host = result.hostname = authInHost.shift();
22050 }
22051 }
22052 result.search = relative.search;
22053 result.query = relative.query;
22054 //to support http.request
22055 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
22056 result.path = (result.pathname ? result.pathname : '') +
22057 (result.search ? result.search : '');
22058 }
22059 result.href = result.format();
22060 return result;
22061 }
22062
22063 if (!srcPath.length) {
22064 // no path at all. easy.
22065 // we've already handled the other stuff above.
22066 result.pathname = null;
22067 //to support http.request
22068 if (result.search) {
22069 result.path = '/' + result.search;
22070 } else {
22071 result.path = null;
22072 }
22073 result.href = result.format();
22074 return result;
22075 }
22076
22077 // if a url ENDs in . or .., then it must get a trailing slash.
22078 // however, if it ends in anything else non-slashy,
22079 // then it must NOT get a trailing slash.
22080 var last = srcPath.slice(-1)[0];
22081 var hasTrailingSlash = (
22082 (result.host || relative.host || srcPath.length > 1) &&
22083 (last === '.' || last === '..') || last === '');
22084
22085 // strip single dots, resolve double dots to parent dir
22086 // if the path tries to go above the root, `up` ends up > 0
22087 var up = 0;
22088 for (var i = srcPath.length; i >= 0; i--) {
22089 last = srcPath[i];
22090 if (last === '.') {
22091 srcPath.splice(i, 1);
22092 } else if (last === '..') {
22093 srcPath.splice(i, 1);
22094 up++;
22095 } else if (up) {
22096 srcPath.splice(i, 1);
22097 up--;
22098 }
22099 }
22100
22101 // if the path is allowed to go above the root, restore leading ..s
22102 if (!mustEndAbs && !removeAllDots) {
22103 for (; up--; up) {
22104 srcPath.unshift('..');
22105 }
22106 }
22107
22108 if (mustEndAbs && srcPath[0] !== '' &&
22109 (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
22110 srcPath.unshift('');
22111 }
22112
22113 if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
22114 srcPath.push('');
22115 }
22116
22117 var isAbsolute = srcPath[0] === '' ||
22118 (srcPath[0] && srcPath[0].charAt(0) === '/');
22119
22120 // put the host back
22121 if (psychotic) {
22122 result.hostname = result.host = isAbsolute ? '' :
22123 srcPath.length ? srcPath.shift() : '';
22124 //occationaly the auth can get stuck only in host
22125 //this especially happens in cases like
22126 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
22127 var authInHost = result.host && result.host.indexOf('@') > 0 ?
22128 result.host.split('@') : false;
22129 if (authInHost) {
22130 result.auth = authInHost.shift();
22131 result.host = result.hostname = authInHost.shift();
22132 }
22133 }
22134
22135 mustEndAbs = mustEndAbs || (result.host && srcPath.length);
22136
22137 if (mustEndAbs && !isAbsolute) {
22138 srcPath.unshift('');
22139 }
22140
22141 if (!srcPath.length) {
22142 result.pathname = null;
22143 result.path = null;
22144 } else {
22145 result.pathname = srcPath.join('/');
22146 }
22147
22148 //to support request.http
22149 if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
22150 result.path = (result.pathname ? result.pathname : '') +
22151 (result.search ? result.search : '');
22152 }
22153 result.auth = relative.auth || result.auth;
22154 result.slashes = result.slashes || relative.slashes;
22155 result.href = result.format();
22156 return result;
22157};
22158
22159Url.prototype.parseHost = function() {
22160 var host = this.host;
22161 var port = portPattern.exec(host);
22162 if (port) {
22163 port = port[0];
22164 if (port !== ':') {
22165 this.port = port.substr(1);
22166 }
22167 host = host.substr(0, host.length - port.length);
22168 }
22169 if (host) this.hostname = host;
22170};
22171
22172},{"./util":149,"punycode":8,"querystring":128}],149:[function(require,module,exports){
22173'use strict';
22174
22175module.exports = {
22176 isString: function(arg) {
22177 return typeof(arg) === 'string';
22178 },
22179 isObject: function(arg) {
22180 return typeof(arg) === 'object' && arg !== null;
22181 },
22182 isNull: function(arg) {
22183 return arg === null;
22184 },
22185 isNullOrUndefined: function(arg) {
22186 return arg == null;
22187 }
22188};
22189
22190},{}],150:[function(require,module,exports){
22191(function (global){
22192
22193/**
22194 * Module exports.
22195 */
22196
22197module.exports = deprecate;
22198
22199/**
22200 * Mark that a method should not be used.
22201 * Returns a modified function which warns once by default.
22202 *
22203 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
22204 *
22205 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
22206 * will throw an Error when invoked.
22207 *
22208 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
22209 * will invoke `console.trace()` instead of `console.error()`.
22210 *
22211 * @param {Function} fn - the function to deprecate
22212 * @param {String} msg - the string to print to the console when `fn` is invoked
22213 * @returns {Function} a new "deprecated" version of `fn`
22214 * @api public
22215 */
22216
22217function deprecate (fn, msg) {
22218 if (config('noDeprecation')) {
22219 return fn;
22220 }
22221
22222 var warned = false;
22223 function deprecated() {
22224 if (!warned) {
22225 if (config('throwDeprecation')) {
22226 throw new Error(msg);
22227 } else if (config('traceDeprecation')) {
22228 console.trace(msg);
22229 } else {
22230 console.warn(msg);
22231 }
22232 warned = true;
22233 }
22234 return fn.apply(this, arguments);
22235 }
22236
22237 return deprecated;
22238}
22239
22240/**
22241 * Checks `localStorage` for boolean values for the given `name`.
22242 *
22243 * @param {String} name
22244 * @returns {Boolean}
22245 * @api private
22246 */
22247
22248function config (name) {
22249 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
22250 try {
22251 if (!global.localStorage) return false;
22252 } catch (_) {
22253 return false;
22254 }
22255 var val = global.localStorage[name];
22256 if (null == val) return false;
22257 return String(val).toLowerCase() === 'true';
22258}
22259
22260}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22261
22262},{}],151:[function(require,module,exports){
22263module.exports = function isBuffer(arg) {
22264 return arg && typeof arg === 'object'
22265 && typeof arg.copy === 'function'
22266 && typeof arg.fill === 'function'
22267 && typeof arg.readUInt8 === 'function';
22268}
22269},{}],152:[function(require,module,exports){
22270(function (process,global){
22271// Copyright Joyent, Inc. and other Node contributors.
22272//
22273// Permission is hereby granted, free of charge, to any person obtaining a
22274// copy of this software and associated documentation files (the
22275// "Software"), to deal in the Software without restriction, including
22276// without limitation the rights to use, copy, modify, merge, publish,
22277// distribute, sublicense, and/or sell copies of the Software, and to permit
22278// persons to whom the Software is furnished to do so, subject to the
22279// following conditions:
22280//
22281// The above copyright notice and this permission notice shall be included
22282// in all copies or substantial portions of the Software.
22283//
22284// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22285// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22286// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22287// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22288// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22289// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22290// USE OR OTHER DEALINGS IN THE SOFTWARE.
22291
22292var formatRegExp = /%[sdj%]/g;
22293exports.format = function(f) {
22294 if (!isString(f)) {
22295 var objects = [];
22296 for (var i = 0; i < arguments.length; i++) {
22297 objects.push(inspect(arguments[i]));
22298 }
22299 return objects.join(' ');
22300 }
22301
22302 var i = 1;
22303 var args = arguments;
22304 var len = args.length;
22305 var str = String(f).replace(formatRegExp, function(x) {
22306 if (x === '%%') return '%';
22307 if (i >= len) return x;
22308 switch (x) {
22309 case '%s': return String(args[i++]);
22310 case '%d': return Number(args[i++]);
22311 case '%j':
22312 try {
22313 return JSON.stringify(args[i++]);
22314 } catch (_) {
22315 return '[Circular]';
22316 }
22317 default:
22318 return x;
22319 }
22320 });
22321 for (var x = args[i]; i < len; x = args[++i]) {
22322 if (isNull(x) || !isObject(x)) {
22323 str += ' ' + x;
22324 } else {
22325 str += ' ' + inspect(x);
22326 }
22327 }
22328 return str;
22329};
22330
22331
22332// Mark that a method should not be used.
22333// Returns a modified function which warns once by default.
22334// If --no-deprecation is set, then it is a no-op.
22335exports.deprecate = function(fn, msg) {
22336 // Allow for deprecating things in the process of starting up.
22337 if (isUndefined(global.process)) {
22338 return function() {
22339 return exports.deprecate(fn, msg).apply(this, arguments);
22340 };
22341 }
22342
22343 if (process.noDeprecation === true) {
22344 return fn;
22345 }
22346
22347 var warned = false;
22348 function deprecated() {
22349 if (!warned) {
22350 if (process.throwDeprecation) {
22351 throw new Error(msg);
22352 } else if (process.traceDeprecation) {
22353 console.trace(msg);
22354 } else {
22355 console.error(msg);
22356 }
22357 warned = true;
22358 }
22359 return fn.apply(this, arguments);
22360 }
22361
22362 return deprecated;
22363};
22364
22365
22366var debugs = {};
22367var debugEnviron;
22368exports.debuglog = function(set) {
22369 if (isUndefined(debugEnviron))
22370 debugEnviron = process.env.NODE_DEBUG || '';
22371 set = set.toUpperCase();
22372 if (!debugs[set]) {
22373 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
22374 var pid = process.pid;
22375 debugs[set] = function() {
22376 var msg = exports.format.apply(exports, arguments);
22377 console.error('%s %d: %s', set, pid, msg);
22378 };
22379 } else {
22380 debugs[set] = function() {};
22381 }
22382 }
22383 return debugs[set];
22384};
22385
22386
22387/**
22388 * Echos the value of a value. Trys to print the value out
22389 * in the best way possible given the different types.
22390 *
22391 * @param {Object} obj The object to print out.
22392 * @param {Object} opts Optional options object that alters the output.
22393 */
22394/* legacy: obj, showHidden, depth, colors*/
22395function inspect(obj, opts) {
22396 // default options
22397 var ctx = {
22398 seen: [],
22399 stylize: stylizeNoColor
22400 };
22401 // legacy...
22402 if (arguments.length >= 3) ctx.depth = arguments[2];
22403 if (arguments.length >= 4) ctx.colors = arguments[3];
22404 if (isBoolean(opts)) {
22405 // legacy...
22406 ctx.showHidden = opts;
22407 } else if (opts) {
22408 // got an "options" object
22409 exports._extend(ctx, opts);
22410 }
22411 // set default options
22412 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
22413 if (isUndefined(ctx.depth)) ctx.depth = 2;
22414 if (isUndefined(ctx.colors)) ctx.colors = false;
22415 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
22416 if (ctx.colors) ctx.stylize = stylizeWithColor;
22417 return formatValue(ctx, obj, ctx.depth);
22418}
22419exports.inspect = inspect;
22420
22421
22422// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
22423inspect.colors = {
22424 'bold' : [1, 22],
22425 'italic' : [3, 23],
22426 'underline' : [4, 24],
22427 'inverse' : [7, 27],
22428 'white' : [37, 39],
22429 'grey' : [90, 39],
22430 'black' : [30, 39],
22431 'blue' : [34, 39],
22432 'cyan' : [36, 39],
22433 'green' : [32, 39],
22434 'magenta' : [35, 39],
22435 'red' : [31, 39],
22436 'yellow' : [33, 39]
22437};
22438
22439// Don't use 'blue' not visible on cmd.exe
22440inspect.styles = {
22441 'special': 'cyan',
22442 'number': 'yellow',
22443 'boolean': 'yellow',
22444 'undefined': 'grey',
22445 'null': 'bold',
22446 'string': 'green',
22447 'date': 'magenta',
22448 // "name": intentionally not styling
22449 'regexp': 'red'
22450};
22451
22452
22453function stylizeWithColor(str, styleType) {
22454 var style = inspect.styles[styleType];
22455
22456 if (style) {
22457 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
22458 '\u001b[' + inspect.colors[style][1] + 'm';
22459 } else {
22460 return str;
22461 }
22462}
22463
22464
22465function stylizeNoColor(str, styleType) {
22466 return str;
22467}
22468
22469
22470function arrayToHash(array) {
22471 var hash = {};
22472
22473 array.forEach(function(val, idx) {
22474 hash[val] = true;
22475 });
22476
22477 return hash;
22478}
22479
22480
22481function formatValue(ctx, value, recurseTimes) {
22482 // Provide a hook for user-specified inspect functions.
22483 // Check that value is an object with an inspect function on it
22484 if (ctx.customInspect &&
22485 value &&
22486 isFunction(value.inspect) &&
22487 // Filter out the util module, it's inspect function is special
22488 value.inspect !== exports.inspect &&
22489 // Also filter out any prototype objects using the circular check.
22490 !(value.constructor && value.constructor.prototype === value)) {
22491 var ret = value.inspect(recurseTimes, ctx);
22492 if (!isString(ret)) {
22493 ret = formatValue(ctx, ret, recurseTimes);
22494 }
22495 return ret;
22496 }
22497
22498 // Primitive types cannot have properties
22499 var primitive = formatPrimitive(ctx, value);
22500 if (primitive) {
22501 return primitive;
22502 }
22503
22504 // Look up the keys of the object.
22505 var keys = Object.keys(value);
22506 var visibleKeys = arrayToHash(keys);
22507
22508 if (ctx.showHidden) {
22509 keys = Object.getOwnPropertyNames(value);
22510 }
22511
22512 // IE doesn't make error fields non-enumerable
22513 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
22514 if (isError(value)
22515 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
22516 return formatError(value);
22517 }
22518
22519 // Some type of object without properties can be shortcutted.
22520 if (keys.length === 0) {
22521 if (isFunction(value)) {
22522 var name = value.name ? ': ' + value.name : '';
22523 return ctx.stylize('[Function' + name + ']', 'special');
22524 }
22525 if (isRegExp(value)) {
22526 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
22527 }
22528 if (isDate(value)) {
22529 return ctx.stylize(Date.prototype.toString.call(value), 'date');
22530 }
22531 if (isError(value)) {
22532 return formatError(value);
22533 }
22534 }
22535
22536 var base = '', array = false, braces = ['{', '}'];
22537
22538 // Make Array say that they are Array
22539 if (isArray(value)) {
22540 array = true;
22541 braces = ['[', ']'];
22542 }
22543
22544 // Make functions say that they are functions
22545 if (isFunction(value)) {
22546 var n = value.name ? ': ' + value.name : '';
22547 base = ' [Function' + n + ']';
22548 }
22549
22550 // Make RegExps say that they are RegExps
22551 if (isRegExp(value)) {
22552 base = ' ' + RegExp.prototype.toString.call(value);
22553 }
22554
22555 // Make dates with properties first say the date
22556 if (isDate(value)) {
22557 base = ' ' + Date.prototype.toUTCString.call(value);
22558 }
22559
22560 // Make error with message first say the error
22561 if (isError(value)) {
22562 base = ' ' + formatError(value);
22563 }
22564
22565 if (keys.length === 0 && (!array || value.length == 0)) {
22566 return braces[0] + base + braces[1];
22567 }
22568
22569 if (recurseTimes < 0) {
22570 if (isRegExp(value)) {
22571 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
22572 } else {
22573 return ctx.stylize('[Object]', 'special');
22574 }
22575 }
22576
22577 ctx.seen.push(value);
22578
22579 var output;
22580 if (array) {
22581 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
22582 } else {
22583 output = keys.map(function(key) {
22584 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
22585 });
22586 }
22587
22588 ctx.seen.pop();
22589
22590 return reduceToSingleString(output, base, braces);
22591}
22592
22593
22594function formatPrimitive(ctx, value) {
22595 if (isUndefined(value))
22596 return ctx.stylize('undefined', 'undefined');
22597 if (isString(value)) {
22598 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
22599 .replace(/'/g, "\\'")
22600 .replace(/\\"/g, '"') + '\'';
22601 return ctx.stylize(simple, 'string');
22602 }
22603 if (isNumber(value))
22604 return ctx.stylize('' + value, 'number');
22605 if (isBoolean(value))
22606 return ctx.stylize('' + value, 'boolean');
22607 // For some reason typeof null is "object", so special case here.
22608 if (isNull(value))
22609 return ctx.stylize('null', 'null');
22610}
22611
22612
22613function formatError(value) {
22614 return '[' + Error.prototype.toString.call(value) + ']';
22615}
22616
22617
22618function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
22619 var output = [];
22620 for (var i = 0, l = value.length; i < l; ++i) {
22621 if (hasOwnProperty(value, String(i))) {
22622 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
22623 String(i), true));
22624 } else {
22625 output.push('');
22626 }
22627 }
22628 keys.forEach(function(key) {
22629 if (!key.match(/^\d+$/)) {
22630 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
22631 key, true));
22632 }
22633 });
22634 return output;
22635}
22636
22637
22638function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
22639 var name, str, desc;
22640 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
22641 if (desc.get) {
22642 if (desc.set) {
22643 str = ctx.stylize('[Getter/Setter]', 'special');
22644 } else {
22645 str = ctx.stylize('[Getter]', 'special');
22646 }
22647 } else {
22648 if (desc.set) {
22649 str = ctx.stylize('[Setter]', 'special');
22650 }
22651 }
22652 if (!hasOwnProperty(visibleKeys, key)) {
22653 name = '[' + key + ']';
22654 }
22655 if (!str) {
22656 if (ctx.seen.indexOf(desc.value) < 0) {
22657 if (isNull(recurseTimes)) {
22658 str = formatValue(ctx, desc.value, null);
22659 } else {
22660 str = formatValue(ctx, desc.value, recurseTimes - 1);
22661 }
22662 if (str.indexOf('\n') > -1) {
22663 if (array) {
22664 str = str.split('\n').map(function(line) {
22665 return ' ' + line;
22666 }).join('\n').substr(2);
22667 } else {
22668 str = '\n' + str.split('\n').map(function(line) {
22669 return ' ' + line;
22670 }).join('\n');
22671 }
22672 }
22673 } else {
22674 str = ctx.stylize('[Circular]', 'special');
22675 }
22676 }
22677 if (isUndefined(name)) {
22678 if (array && key.match(/^\d+$/)) {
22679 return str;
22680 }
22681 name = JSON.stringify('' + key);
22682 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
22683 name = name.substr(1, name.length - 2);
22684 name = ctx.stylize(name, 'name');
22685 } else {
22686 name = name.replace(/'/g, "\\'")
22687 .replace(/\\"/g, '"')
22688 .replace(/(^"|"$)/g, "'");
22689 name = ctx.stylize(name, 'string');
22690 }
22691 }
22692
22693 return name + ': ' + str;
22694}
22695
22696
22697function reduceToSingleString(output, base, braces) {
22698 var numLinesEst = 0;
22699 var length = output.reduce(function(prev, cur) {
22700 numLinesEst++;
22701 if (cur.indexOf('\n') >= 0) numLinesEst++;
22702 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
22703 }, 0);
22704
22705 if (length > 60) {
22706 return braces[0] +
22707 (base === '' ? '' : base + '\n ') +
22708 ' ' +
22709 output.join(',\n ') +
22710 ' ' +
22711 braces[1];
22712 }
22713
22714 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
22715}
22716
22717
22718// NOTE: These type checking functions intentionally don't use `instanceof`
22719// because it is fragile and can be easily faked with `Object.create()`.
22720function isArray(ar) {
22721 return Array.isArray(ar);
22722}
22723exports.isArray = isArray;
22724
22725function isBoolean(arg) {
22726 return typeof arg === 'boolean';
22727}
22728exports.isBoolean = isBoolean;
22729
22730function isNull(arg) {
22731 return arg === null;
22732}
22733exports.isNull = isNull;
22734
22735function isNullOrUndefined(arg) {
22736 return arg == null;
22737}
22738exports.isNullOrUndefined = isNullOrUndefined;
22739
22740function isNumber(arg) {
22741 return typeof arg === 'number';
22742}
22743exports.isNumber = isNumber;
22744
22745function isString(arg) {
22746 return typeof arg === 'string';
22747}
22748exports.isString = isString;
22749
22750function isSymbol(arg) {
22751 return typeof arg === 'symbol';
22752}
22753exports.isSymbol = isSymbol;
22754
22755function isUndefined(arg) {
22756 return arg === void 0;
22757}
22758exports.isUndefined = isUndefined;
22759
22760function isRegExp(re) {
22761 return isObject(re) && objectToString(re) === '[object RegExp]';
22762}
22763exports.isRegExp = isRegExp;
22764
22765function isObject(arg) {
22766 return typeof arg === 'object' && arg !== null;
22767}
22768exports.isObject = isObject;
22769
22770function isDate(d) {
22771 return isObject(d) && objectToString(d) === '[object Date]';
22772}
22773exports.isDate = isDate;
22774
22775function isError(e) {
22776 return isObject(e) &&
22777 (objectToString(e) === '[object Error]' || e instanceof Error);
22778}
22779exports.isError = isError;
22780
22781function isFunction(arg) {
22782 return typeof arg === 'function';
22783}
22784exports.isFunction = isFunction;
22785
22786function isPrimitive(arg) {
22787 return arg === null ||
22788 typeof arg === 'boolean' ||
22789 typeof arg === 'number' ||
22790 typeof arg === 'string' ||
22791 typeof arg === 'symbol' || // ES6 symbol
22792 typeof arg === 'undefined';
22793}
22794exports.isPrimitive = isPrimitive;
22795
22796exports.isBuffer = require('./support/isBuffer');
22797
22798function objectToString(o) {
22799 return Object.prototype.toString.call(o);
22800}
22801
22802
22803function pad(n) {
22804 return n < 10 ? '0' + n.toString(10) : n.toString(10);
22805}
22806
22807
22808var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
22809 'Oct', 'Nov', 'Dec'];
22810
22811// 26 Feb 16:19:34
22812function timestamp() {
22813 var d = new Date();
22814 var time = [pad(d.getHours()),
22815 pad(d.getMinutes()),
22816 pad(d.getSeconds())].join(':');
22817 return [d.getDate(), months[d.getMonth()], time].join(' ');
22818}
22819
22820
22821// log is just a thin wrapper to console.log that prepends a timestamp
22822exports.log = function() {
22823 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
22824};
22825
22826
22827/**
22828 * Inherit the prototype methods from one constructor into another.
22829 *
22830 * The Function.prototype.inherits from lang.js rewritten as a standalone
22831 * function (not on Function.prototype). NOTE: If this file is to be loaded
22832 * during bootstrapping this function needs to be rewritten using some native
22833 * functions as prototype setup using normal JavaScript does not work as
22834 * expected during bootstrapping (see mirror.js in r114903).
22835 *
22836 * @param {function} ctor Constructor function which needs to inherit the
22837 * prototype.
22838 * @param {function} superCtor Constructor function to inherit prototype from.
22839 */
22840exports.inherits = require('inherits');
22841
22842exports._extend = function(origin, add) {
22843 // Don't do anything if add isn't an object
22844 if (!add || !isObject(add)) return origin;
22845
22846 var keys = Object.keys(add);
22847 var i = keys.length;
22848 while (i--) {
22849 origin[keys[i]] = add[keys[i]];
22850 }
22851 return origin;
22852};
22853
22854function hasOwnProperty(obj, prop) {
22855 return Object.prototype.hasOwnProperty.call(obj, prop);
22856}
22857
22858}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22859
22860},{"./support/isBuffer":151,"_process":125,"inherits":68}],153:[function(require,module,exports){
22861"use strict";
22862
22863Object.defineProperty(exports, "__esModule", {
22864 value: true
22865});
22866exports.default = void 0;
22867
22868var _toDate = _interopRequireDefault(require("./lib/toDate"));
22869
22870var _toFloat = _interopRequireDefault(require("./lib/toFloat"));
22871
22872var _toInt = _interopRequireDefault(require("./lib/toInt"));
22873
22874var _toBoolean = _interopRequireDefault(require("./lib/toBoolean"));
22875
22876var _equals = _interopRequireDefault(require("./lib/equals"));
22877
22878var _contains = _interopRequireDefault(require("./lib/contains"));
22879
22880var _matches = _interopRequireDefault(require("./lib/matches"));
22881
22882var _isEmail = _interopRequireDefault(require("./lib/isEmail"));
22883
22884var _isURL = _interopRequireDefault(require("./lib/isURL"));
22885
22886var _isMACAddress = _interopRequireDefault(require("./lib/isMACAddress"));
22887
22888var _isIP = _interopRequireDefault(require("./lib/isIP"));
22889
22890var _isIPRange = _interopRequireDefault(require("./lib/isIPRange"));
22891
22892var _isFQDN = _interopRequireDefault(require("./lib/isFQDN"));
22893
22894var _isBoolean = _interopRequireDefault(require("./lib/isBoolean"));
22895
22896var _isAlpha = _interopRequireWildcard(require("./lib/isAlpha"));
22897
22898var _isAlphanumeric = _interopRequireWildcard(require("./lib/isAlphanumeric"));
22899
22900var _isNumeric = _interopRequireDefault(require("./lib/isNumeric"));
22901
22902var _isPort = _interopRequireDefault(require("./lib/isPort"));
22903
22904var _isLowercase = _interopRequireDefault(require("./lib/isLowercase"));
22905
22906var _isUppercase = _interopRequireDefault(require("./lib/isUppercase"));
22907
22908var _isAscii = _interopRequireDefault(require("./lib/isAscii"));
22909
22910var _isFullWidth = _interopRequireDefault(require("./lib/isFullWidth"));
22911
22912var _isHalfWidth = _interopRequireDefault(require("./lib/isHalfWidth"));
22913
22914var _isVariableWidth = _interopRequireDefault(require("./lib/isVariableWidth"));
22915
22916var _isMultibyte = _interopRequireDefault(require("./lib/isMultibyte"));
22917
22918var _isSurrogatePair = _interopRequireDefault(require("./lib/isSurrogatePair"));
22919
22920var _isInt = _interopRequireDefault(require("./lib/isInt"));
22921
22922var _isFloat = _interopRequireWildcard(require("./lib/isFloat"));
22923
22924var _isDecimal = _interopRequireDefault(require("./lib/isDecimal"));
22925
22926var _isHexadecimal = _interopRequireDefault(require("./lib/isHexadecimal"));
22927
22928var _isDivisibleBy = _interopRequireDefault(require("./lib/isDivisibleBy"));
22929
22930var _isHexColor = _interopRequireDefault(require("./lib/isHexColor"));
22931
22932var _isISRC = _interopRequireDefault(require("./lib/isISRC"));
22933
22934var _isMD = _interopRequireDefault(require("./lib/isMD5"));
22935
22936var _isHash = _interopRequireDefault(require("./lib/isHash"));
22937
22938var _isJWT = _interopRequireDefault(require("./lib/isJWT"));
22939
22940var _isJSON = _interopRequireDefault(require("./lib/isJSON"));
22941
22942var _isEmpty = _interopRequireDefault(require("./lib/isEmpty"));
22943
22944var _isLength = _interopRequireDefault(require("./lib/isLength"));
22945
22946var _isByteLength = _interopRequireDefault(require("./lib/isByteLength"));
22947
22948var _isUUID = _interopRequireDefault(require("./lib/isUUID"));
22949
22950var _isMongoId = _interopRequireDefault(require("./lib/isMongoId"));
22951
22952var _isAfter = _interopRequireDefault(require("./lib/isAfter"));
22953
22954var _isBefore = _interopRequireDefault(require("./lib/isBefore"));
22955
22956var _isIn = _interopRequireDefault(require("./lib/isIn"));
22957
22958var _isCreditCard = _interopRequireDefault(require("./lib/isCreditCard"));
22959
22960var _isIdentityCard = _interopRequireDefault(require("./lib/isIdentityCard"));
22961
22962var _isISIN = _interopRequireDefault(require("./lib/isISIN"));
22963
22964var _isISBN = _interopRequireDefault(require("./lib/isISBN"));
22965
22966var _isISSN = _interopRequireDefault(require("./lib/isISSN"));
22967
22968var _isMobilePhone = _interopRequireWildcard(require("./lib/isMobilePhone"));
22969
22970var _isCurrency = _interopRequireDefault(require("./lib/isCurrency"));
22971
22972var _isISO = _interopRequireDefault(require("./lib/isISO8601"));
22973
22974var _isRFC = _interopRequireDefault(require("./lib/isRFC3339"));
22975
22976var _isISO31661Alpha = _interopRequireDefault(require("./lib/isISO31661Alpha2"));
22977
22978var _isISO31661Alpha2 = _interopRequireDefault(require("./lib/isISO31661Alpha3"));
22979
22980var _isBase = _interopRequireDefault(require("./lib/isBase64"));
22981
22982var _isDataURI = _interopRequireDefault(require("./lib/isDataURI"));
22983
22984var _isMagnetURI = _interopRequireDefault(require("./lib/isMagnetURI"));
22985
22986var _isMimeType = _interopRequireDefault(require("./lib/isMimeType"));
22987
22988var _isLatLong = _interopRequireDefault(require("./lib/isLatLong"));
22989
22990var _isPostalCode = _interopRequireWildcard(require("./lib/isPostalCode"));
22991
22992var _ltrim = _interopRequireDefault(require("./lib/ltrim"));
22993
22994var _rtrim = _interopRequireDefault(require("./lib/rtrim"));
22995
22996var _trim = _interopRequireDefault(require("./lib/trim"));
22997
22998var _escape = _interopRequireDefault(require("./lib/escape"));
22999
23000var _unescape = _interopRequireDefault(require("./lib/unescape"));
23001
23002var _stripLow = _interopRequireDefault(require("./lib/stripLow"));
23003
23004var _whitelist = _interopRequireDefault(require("./lib/whitelist"));
23005
23006var _blacklist = _interopRequireDefault(require("./lib/blacklist"));
23007
23008var _isWhitelisted = _interopRequireDefault(require("./lib/isWhitelisted"));
23009
23010var _normalizeEmail = _interopRequireDefault(require("./lib/normalizeEmail"));
23011
23012var _toString = _interopRequireDefault(require("./lib/util/toString"));
23013
23014function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
23015
23016function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23017
23018var version = '10.11.0';
23019var validator = {
23020 version: version,
23021 toDate: _toDate.default,
23022 toFloat: _toFloat.default,
23023 toInt: _toInt.default,
23024 toBoolean: _toBoolean.default,
23025 equals: _equals.default,
23026 contains: _contains.default,
23027 matches: _matches.default,
23028 isEmail: _isEmail.default,
23029 isURL: _isURL.default,
23030 isMACAddress: _isMACAddress.default,
23031 isIP: _isIP.default,
23032 isIPRange: _isIPRange.default,
23033 isFQDN: _isFQDN.default,
23034 isBoolean: _isBoolean.default,
23035 isAlpha: _isAlpha.default,
23036 isAlphaLocales: _isAlpha.locales,
23037 isAlphanumeric: _isAlphanumeric.default,
23038 isAlphanumericLocales: _isAlphanumeric.locales,
23039 isNumeric: _isNumeric.default,
23040 isPort: _isPort.default,
23041 isLowercase: _isLowercase.default,
23042 isUppercase: _isUppercase.default,
23043 isAscii: _isAscii.default,
23044 isFullWidth: _isFullWidth.default,
23045 isHalfWidth: _isHalfWidth.default,
23046 isVariableWidth: _isVariableWidth.default,
23047 isMultibyte: _isMultibyte.default,
23048 isSurrogatePair: _isSurrogatePair.default,
23049 isInt: _isInt.default,
23050 isFloat: _isFloat.default,
23051 isFloatLocales: _isFloat.locales,
23052 isDecimal: _isDecimal.default,
23053 isHexadecimal: _isHexadecimal.default,
23054 isDivisibleBy: _isDivisibleBy.default,
23055 isHexColor: _isHexColor.default,
23056 isISRC: _isISRC.default,
23057 isMD5: _isMD.default,
23058 isHash: _isHash.default,
23059 isJWT: _isJWT.default,
23060 isJSON: _isJSON.default,
23061 isEmpty: _isEmpty.default,
23062 isLength: _isLength.default,
23063 isByteLength: _isByteLength.default,
23064 isUUID: _isUUID.default,
23065 isMongoId: _isMongoId.default,
23066 isAfter: _isAfter.default,
23067 isBefore: _isBefore.default,
23068 isIn: _isIn.default,
23069 isCreditCard: _isCreditCard.default,
23070 isIdentityCard: _isIdentityCard.default,
23071 isISIN: _isISIN.default,
23072 isISBN: _isISBN.default,
23073 isISSN: _isISSN.default,
23074 isMobilePhone: _isMobilePhone.default,
23075 isMobilePhoneLocales: _isMobilePhone.locales,
23076 isPostalCode: _isPostalCode.default,
23077 isPostalCodeLocales: _isPostalCode.locales,
23078 isCurrency: _isCurrency.default,
23079 isISO8601: _isISO.default,
23080 isRFC3339: _isRFC.default,
23081 isISO31661Alpha2: _isISO31661Alpha.default,
23082 isISO31661Alpha3: _isISO31661Alpha2.default,
23083 isBase64: _isBase.default,
23084 isDataURI: _isDataURI.default,
23085 isMagnetURI: _isMagnetURI.default,
23086 isMimeType: _isMimeType.default,
23087 isLatLong: _isLatLong.default,
23088 ltrim: _ltrim.default,
23089 rtrim: _rtrim.default,
23090 trim: _trim.default,
23091 escape: _escape.default,
23092 unescape: _unescape.default,
23093 stripLow: _stripLow.default,
23094 whitelist: _whitelist.default,
23095 blacklist: _blacklist.default,
23096 isWhitelisted: _isWhitelisted.default,
23097 normalizeEmail: _normalizeEmail.default,
23098 toString: _toString.default
23099};
23100var _default = validator;
23101exports.default = _default;
23102module.exports = exports.default;
23103module.exports.default = exports.default;
23104},{"./lib/blacklist":155,"./lib/contains":156,"./lib/equals":157,"./lib/escape":158,"./lib/isAfter":159,"./lib/isAlpha":160,"./lib/isAlphanumeric":161,"./lib/isAscii":162,"./lib/isBase64":163,"./lib/isBefore":164,"./lib/isBoolean":165,"./lib/isByteLength":166,"./lib/isCreditCard":167,"./lib/isCurrency":168,"./lib/isDataURI":169,"./lib/isDecimal":170,"./lib/isDivisibleBy":171,"./lib/isEmail":172,"./lib/isEmpty":173,"./lib/isFQDN":174,"./lib/isFloat":175,"./lib/isFullWidth":176,"./lib/isHalfWidth":177,"./lib/isHash":178,"./lib/isHexColor":179,"./lib/isHexadecimal":180,"./lib/isIP":181,"./lib/isIPRange":182,"./lib/isISBN":183,"./lib/isISIN":184,"./lib/isISO31661Alpha2":185,"./lib/isISO31661Alpha3":186,"./lib/isISO8601":187,"./lib/isISRC":188,"./lib/isISSN":189,"./lib/isIdentityCard":190,"./lib/isIn":191,"./lib/isInt":192,"./lib/isJSON":193,"./lib/isJWT":194,"./lib/isLatLong":195,"./lib/isLength":196,"./lib/isLowercase":197,"./lib/isMACAddress":198,"./lib/isMD5":199,"./lib/isMagnetURI":200,"./lib/isMimeType":201,"./lib/isMobilePhone":202,"./lib/isMongoId":203,"./lib/isMultibyte":204,"./lib/isNumeric":205,"./lib/isPort":206,"./lib/isPostalCode":207,"./lib/isRFC3339":208,"./lib/isSurrogatePair":209,"./lib/isURL":210,"./lib/isUUID":211,"./lib/isUppercase":212,"./lib/isVariableWidth":213,"./lib/isWhitelisted":214,"./lib/ltrim":215,"./lib/matches":216,"./lib/normalizeEmail":217,"./lib/rtrim":218,"./lib/stripLow":219,"./lib/toBoolean":220,"./lib/toDate":221,"./lib/toFloat":222,"./lib/toInt":223,"./lib/trim":224,"./lib/unescape":225,"./lib/util/toString":229,"./lib/whitelist":230}],154:[function(require,module,exports){
23105"use strict";
23106
23107Object.defineProperty(exports, "__esModule", {
23108 value: true
23109});
23110exports.commaDecimal = exports.dotDecimal = exports.arabicLocales = exports.englishLocales = exports.decimal = exports.alphanumeric = exports.alpha = void 0;
23111var alpha = {
23112 'en-US': /^[A-Z]+$/i,
23113 'bg-BG': /^[А-Я]+$/i,
23114 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
23115 'da-DK': /^[A-ZÆØÅ]+$/i,
23116 'de-DE': /^[A-ZÄÖÜß]+$/i,
23117 'el-GR': /^[Α-ω]+$/i,
23118 'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
23119 'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
23120 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
23121 'nb-NO': /^[A-ZÆØÅ]+$/i,
23122 'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
23123 'nn-NO': /^[A-ZÆØÅ]+$/i,
23124 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
23125 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
23126 'pt-PT': /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,
23127 'ru-RU': /^[А-ЯЁ]+$/i,
23128 'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
23129 'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
23130 'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
23131 'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
23132 'sv-SE': /^[A-ZÅÄÖ]+$/i,
23133 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
23134 'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
23135 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
23136 ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
23137};
23138exports.alpha = alpha;
23139var alphanumeric = {
23140 'en-US': /^[0-9A-Z]+$/i,
23141 'bg-BG': /^[0-9А-Я]+$/i,
23142 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
23143 'da-DK': /^[0-9A-ZÆØÅ]+$/i,
23144 'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
23145 'el-GR': /^[0-9Α-ω]+$/i,
23146 'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
23147 'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
23148 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
23149 'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
23150 'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
23151 'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
23152 'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
23153 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
23154 'pt-PT': /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,
23155 'ru-RU': /^[0-9А-ЯЁ]+$/i,
23156 'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
23157 'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
23158 'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
23159 'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
23160 'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
23161 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
23162 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
23163 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
23164 ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
23165};
23166exports.alphanumeric = alphanumeric;
23167var decimal = {
23168 'en-US': '.',
23169 ar: '٫'
23170};
23171exports.decimal = decimal;
23172var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
23173exports.englishLocales = englishLocales;
23174
23175for (var locale, i = 0; i < englishLocales.length; i++) {
23176 locale = "en-".concat(englishLocales[i]);
23177 alpha[locale] = alpha['en-US'];
23178 alphanumeric[locale] = alphanumeric['en-US'];
23179 decimal[locale] = decimal['en-US'];
23180} // Source: http://www.localeplanet.com/java/
23181
23182
23183var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
23184exports.arabicLocales = arabicLocales;
23185
23186for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
23187 _locale = "ar-".concat(arabicLocales[_i]);
23188 alpha[_locale] = alpha.ar;
23189 alphanumeric[_locale] = alphanumeric.ar;
23190 decimal[_locale] = decimal.ar;
23191} // Source: https://en.wikipedia.org/wiki/Decimal_mark
23192
23193
23194var dotDecimal = [];
23195exports.dotDecimal = dotDecimal;
23196var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA'];
23197exports.commaDecimal = commaDecimal;
23198
23199for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
23200 decimal[dotDecimal[_i2]] = decimal['en-US'];
23201}
23202
23203for (var _i3 = 0; _i3 < commaDecimal.length; _i3++) {
23204 decimal[commaDecimal[_i3]] = ',';
23205}
23206
23207alpha['pt-BR'] = alpha['pt-PT'];
23208alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
23209decimal['pt-BR'] = decimal['pt-PT']; // see #862
23210
23211alpha['pl-Pl'] = alpha['pl-PL'];
23212alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
23213decimal['pl-Pl'] = decimal['pl-PL'];
23214},{}],155:[function(require,module,exports){
23215"use strict";
23216
23217Object.defineProperty(exports, "__esModule", {
23218 value: true
23219});
23220exports.default = blacklist;
23221
23222var _assertString = _interopRequireDefault(require("./util/assertString"));
23223
23224function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23225
23226function blacklist(str, chars) {
23227 (0, _assertString.default)(str);
23228 return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), '');
23229}
23230
23231module.exports = exports.default;
23232module.exports.default = exports.default;
23233},{"./util/assertString":226}],156:[function(require,module,exports){
23234"use strict";
23235
23236Object.defineProperty(exports, "__esModule", {
23237 value: true
23238});
23239exports.default = contains;
23240
23241var _assertString = _interopRequireDefault(require("./util/assertString"));
23242
23243var _toString = _interopRequireDefault(require("./util/toString"));
23244
23245function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23246
23247function contains(str, elem) {
23248 (0, _assertString.default)(str);
23249 return str.indexOf((0, _toString.default)(elem)) >= 0;
23250}
23251
23252module.exports = exports.default;
23253module.exports.default = exports.default;
23254},{"./util/assertString":226,"./util/toString":229}],157:[function(require,module,exports){
23255"use strict";
23256
23257Object.defineProperty(exports, "__esModule", {
23258 value: true
23259});
23260exports.default = equals;
23261
23262var _assertString = _interopRequireDefault(require("./util/assertString"));
23263
23264function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23265
23266function equals(str, comparison) {
23267 (0, _assertString.default)(str);
23268 return str === comparison;
23269}
23270
23271module.exports = exports.default;
23272module.exports.default = exports.default;
23273},{"./util/assertString":226}],158:[function(require,module,exports){
23274"use strict";
23275
23276Object.defineProperty(exports, "__esModule", {
23277 value: true
23278});
23279exports.default = escape;
23280
23281var _assertString = _interopRequireDefault(require("./util/assertString"));
23282
23283function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23284
23285function escape(str) {
23286 (0, _assertString.default)(str);
23287 return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\//g, '&#x2F;').replace(/\\/g, '&#x5C;').replace(/`/g, '&#96;');
23288}
23289
23290module.exports = exports.default;
23291module.exports.default = exports.default;
23292},{"./util/assertString":226}],159:[function(require,module,exports){
23293"use strict";
23294
23295Object.defineProperty(exports, "__esModule", {
23296 value: true
23297});
23298exports.default = isAfter;
23299
23300var _assertString = _interopRequireDefault(require("./util/assertString"));
23301
23302var _toDate = _interopRequireDefault(require("./toDate"));
23303
23304function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23305
23306function isAfter(str) {
23307 var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
23308 (0, _assertString.default)(str);
23309 var comparison = (0, _toDate.default)(date);
23310 var original = (0, _toDate.default)(str);
23311 return !!(original && comparison && original > comparison);
23312}
23313
23314module.exports = exports.default;
23315module.exports.default = exports.default;
23316},{"./toDate":221,"./util/assertString":226}],160:[function(require,module,exports){
23317"use strict";
23318
23319Object.defineProperty(exports, "__esModule", {
23320 value: true
23321});
23322exports.default = isAlpha;
23323exports.locales = void 0;
23324
23325var _assertString = _interopRequireDefault(require("./util/assertString"));
23326
23327var _alpha = require("./alpha");
23328
23329function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23330
23331function isAlpha(str) {
23332 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
23333 (0, _assertString.default)(str);
23334
23335 if (locale in _alpha.alpha) {
23336 return _alpha.alpha[locale].test(str);
23337 }
23338
23339 throw new Error("Invalid locale '".concat(locale, "'"));
23340}
23341
23342var locales = Object.keys(_alpha.alpha);
23343exports.locales = locales;
23344},{"./alpha":154,"./util/assertString":226}],161:[function(require,module,exports){
23345"use strict";
23346
23347Object.defineProperty(exports, "__esModule", {
23348 value: true
23349});
23350exports.default = isAlphanumeric;
23351exports.locales = void 0;
23352
23353var _assertString = _interopRequireDefault(require("./util/assertString"));
23354
23355var _alpha = require("./alpha");
23356
23357function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23358
23359function isAlphanumeric(str) {
23360 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
23361 (0, _assertString.default)(str);
23362
23363 if (locale in _alpha.alphanumeric) {
23364 return _alpha.alphanumeric[locale].test(str);
23365 }
23366
23367 throw new Error("Invalid locale '".concat(locale, "'"));
23368}
23369
23370var locales = Object.keys(_alpha.alphanumeric);
23371exports.locales = locales;
23372},{"./alpha":154,"./util/assertString":226}],162:[function(require,module,exports){
23373"use strict";
23374
23375Object.defineProperty(exports, "__esModule", {
23376 value: true
23377});
23378exports.default = isAscii;
23379
23380var _assertString = _interopRequireDefault(require("./util/assertString"));
23381
23382function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23383
23384/* eslint-disable no-control-regex */
23385var ascii = /^[\x00-\x7F]+$/;
23386/* eslint-enable no-control-regex */
23387
23388function isAscii(str) {
23389 (0, _assertString.default)(str);
23390 return ascii.test(str);
23391}
23392
23393module.exports = exports.default;
23394module.exports.default = exports.default;
23395},{"./util/assertString":226}],163:[function(require,module,exports){
23396"use strict";
23397
23398Object.defineProperty(exports, "__esModule", {
23399 value: true
23400});
23401exports.default = isBase64;
23402
23403var _assertString = _interopRequireDefault(require("./util/assertString"));
23404
23405function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23406
23407var notBase64 = /[^A-Z0-9+\/=]/i;
23408
23409function isBase64(str) {
23410 (0, _assertString.default)(str);
23411 var len = str.length;
23412
23413 if (!len || len % 4 !== 0 || notBase64.test(str)) {
23414 return false;
23415 }
23416
23417 var firstPaddingChar = str.indexOf('=');
23418 return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
23419}
23420
23421module.exports = exports.default;
23422module.exports.default = exports.default;
23423},{"./util/assertString":226}],164:[function(require,module,exports){
23424"use strict";
23425
23426Object.defineProperty(exports, "__esModule", {
23427 value: true
23428});
23429exports.default = isBefore;
23430
23431var _assertString = _interopRequireDefault(require("./util/assertString"));
23432
23433var _toDate = _interopRequireDefault(require("./toDate"));
23434
23435function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23436
23437function isBefore(str) {
23438 var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
23439 (0, _assertString.default)(str);
23440 var comparison = (0, _toDate.default)(date);
23441 var original = (0, _toDate.default)(str);
23442 return !!(original && comparison && original < comparison);
23443}
23444
23445module.exports = exports.default;
23446module.exports.default = exports.default;
23447},{"./toDate":221,"./util/assertString":226}],165:[function(require,module,exports){
23448"use strict";
23449
23450Object.defineProperty(exports, "__esModule", {
23451 value: true
23452});
23453exports.default = isBoolean;
23454
23455var _assertString = _interopRequireDefault(require("./util/assertString"));
23456
23457function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23458
23459function isBoolean(str) {
23460 (0, _assertString.default)(str);
23461 return ['true', 'false', '1', '0'].indexOf(str) >= 0;
23462}
23463
23464module.exports = exports.default;
23465module.exports.default = exports.default;
23466},{"./util/assertString":226}],166:[function(require,module,exports){
23467"use strict";
23468
23469Object.defineProperty(exports, "__esModule", {
23470 value: true
23471});
23472exports.default = isByteLength;
23473
23474var _assertString = _interopRequireDefault(require("./util/assertString"));
23475
23476function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23477
23478function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23479
23480/* eslint-disable prefer-rest-params */
23481function isByteLength(str, options) {
23482 (0, _assertString.default)(str);
23483 var min;
23484 var max;
23485
23486 if (_typeof(options) === 'object') {
23487 min = options.min || 0;
23488 max = options.max;
23489 } else {
23490 // backwards compatibility: isByteLength(str, min [, max])
23491 min = arguments[1];
23492 max = arguments[2];
23493 }
23494
23495 var len = encodeURI(str).split(/%..|./).length - 1;
23496 return len >= min && (typeof max === 'undefined' || len <= max);
23497}
23498
23499module.exports = exports.default;
23500module.exports.default = exports.default;
23501},{"./util/assertString":226}],167:[function(require,module,exports){
23502"use strict";
23503
23504Object.defineProperty(exports, "__esModule", {
23505 value: true
23506});
23507exports.default = isCreditCard;
23508
23509var _assertString = _interopRequireDefault(require("./util/assertString"));
23510
23511function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23512
23513/* eslint-disable max-len */
23514var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/;
23515/* eslint-enable max-len */
23516
23517function isCreditCard(str) {
23518 (0, _assertString.default)(str);
23519 var sanitized = str.replace(/[- ]+/g, '');
23520
23521 if (!creditCard.test(sanitized)) {
23522 return false;
23523 }
23524
23525 var sum = 0;
23526 var digit;
23527 var tmpNum;
23528 var shouldDouble;
23529
23530 for (var i = sanitized.length - 1; i >= 0; i--) {
23531 digit = sanitized.substring(i, i + 1);
23532 tmpNum = parseInt(digit, 10);
23533
23534 if (shouldDouble) {
23535 tmpNum *= 2;
23536
23537 if (tmpNum >= 10) {
23538 sum += tmpNum % 10 + 1;
23539 } else {
23540 sum += tmpNum;
23541 }
23542 } else {
23543 sum += tmpNum;
23544 }
23545
23546 shouldDouble = !shouldDouble;
23547 }
23548
23549 return !!(sum % 10 === 0 ? sanitized : false);
23550}
23551
23552module.exports = exports.default;
23553module.exports.default = exports.default;
23554},{"./util/assertString":226}],168:[function(require,module,exports){
23555"use strict";
23556
23557Object.defineProperty(exports, "__esModule", {
23558 value: true
23559});
23560exports.default = isCurrency;
23561
23562var _merge = _interopRequireDefault(require("./util/merge"));
23563
23564var _assertString = _interopRequireDefault(require("./util/assertString"));
23565
23566function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23567
23568function currencyRegex(options) {
23569 var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
23570 options.digits_after_decimal.forEach(function (digit, index) {
23571 if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
23572 });
23573 var symbol = "(\\".concat(options.symbol.replace(/\./g, '\\.'), ")").concat(options.require_symbol ? '' : '?'),
23574 negative = '-?',
23575 whole_dollar_amount_without_sep = '[1-9]\\d*',
23576 whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
23577 valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
23578 whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
23579 decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
23580 var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); // default is negative sign before symbol, but there are two other options (besides parens)
23581
23582 if (options.allow_negatives && !options.parens_for_negatives) {
23583 if (options.negative_sign_after_digits) {
23584 pattern += negative;
23585 } else if (options.negative_sign_before_digits) {
23586 pattern = negative + pattern;
23587 }
23588 } // South African Rand, for example, uses R 123 (space) and R-123 (no space)
23589
23590
23591 if (options.allow_negative_sign_placeholder) {
23592 pattern = "( (?!\\-))?".concat(pattern);
23593 } else if (options.allow_space_after_symbol) {
23594 pattern = " ?".concat(pattern);
23595 } else if (options.allow_space_after_digits) {
23596 pattern += '( (?!$))?';
23597 }
23598
23599 if (options.symbol_after_digits) {
23600 pattern += symbol;
23601 } else {
23602 pattern = symbol + pattern;
23603 }
23604
23605 if (options.allow_negatives) {
23606 if (options.parens_for_negatives) {
23607 pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")");
23608 } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
23609 pattern = negative + pattern;
23610 }
23611 } // ensure there's a dollar and/or decimal amount, and that
23612 // it doesn't start with a space or a negative sign followed by a space
23613
23614
23615 return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
23616}
23617
23618var default_currency_options = {
23619 symbol: '$',
23620 require_symbol: false,
23621 allow_space_after_symbol: false,
23622 symbol_after_digits: false,
23623 allow_negatives: true,
23624 parens_for_negatives: false,
23625 negative_sign_before_digits: false,
23626 negative_sign_after_digits: false,
23627 allow_negative_sign_placeholder: false,
23628 thousands_separator: ',',
23629 decimal_separator: '.',
23630 allow_decimal: true,
23631 require_decimal: false,
23632 digits_after_decimal: [2],
23633 allow_space_after_digits: false
23634};
23635
23636function isCurrency(str, options) {
23637 (0, _assertString.default)(str);
23638 options = (0, _merge.default)(options, default_currency_options);
23639 return currencyRegex(options).test(str);
23640}
23641
23642module.exports = exports.default;
23643module.exports.default = exports.default;
23644},{"./util/assertString":226,"./util/merge":228}],169:[function(require,module,exports){
23645"use strict";
23646
23647Object.defineProperty(exports, "__esModule", {
23648 value: true
23649});
23650exports.default = isDataURI;
23651
23652var _assertString = _interopRequireDefault(require("./util/assertString"));
23653
23654function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23655
23656var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
23657var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
23658var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
23659
23660function isDataURI(str) {
23661 (0, _assertString.default)(str);
23662 var data = str.split(',');
23663
23664 if (data.length < 2) {
23665 return false;
23666 }
23667
23668 var attributes = data.shift().trim().split(';');
23669 var schemeAndMediaType = attributes.shift();
23670
23671 if (schemeAndMediaType.substr(0, 5) !== 'data:') {
23672 return false;
23673 }
23674
23675 var mediaType = schemeAndMediaType.substr(5);
23676
23677 if (mediaType !== '' && !validMediaType.test(mediaType)) {
23678 return false;
23679 }
23680
23681 for (var i = 0; i < attributes.length; i++) {
23682 if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {// ok
23683 } else if (!validAttribute.test(attributes[i])) {
23684 return false;
23685 }
23686 }
23687
23688 for (var _i = 0; _i < data.length; _i++) {
23689 if (!validData.test(data[_i])) {
23690 return false;
23691 }
23692 }
23693
23694 return true;
23695}
23696
23697module.exports = exports.default;
23698module.exports.default = exports.default;
23699},{"./util/assertString":226}],170:[function(require,module,exports){
23700"use strict";
23701
23702Object.defineProperty(exports, "__esModule", {
23703 value: true
23704});
23705exports.default = isDecimal;
23706
23707var _merge = _interopRequireDefault(require("./util/merge"));
23708
23709var _assertString = _interopRequireDefault(require("./util/assertString"));
23710
23711var _includes = _interopRequireDefault(require("./util/includes"));
23712
23713var _alpha = require("./alpha");
23714
23715function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23716
23717function decimalRegExp(options) {
23718 var regExp = new RegExp("^[-+]?([0-9]+)?(\\".concat(_alpha.decimal[options.locale], "[0-9]{").concat(options.decimal_digits, "})").concat(options.force_decimal ? '' : '?', "$"));
23719 return regExp;
23720}
23721
23722var default_decimal_options = {
23723 force_decimal: false,
23724 decimal_digits: '1,',
23725 locale: 'en-US'
23726};
23727var blacklist = ['', '-', '+'];
23728
23729function isDecimal(str, options) {
23730 (0, _assertString.default)(str);
23731 options = (0, _merge.default)(options, default_decimal_options);
23732
23733 if (options.locale in _alpha.decimal) {
23734 return !(0, _includes.default)(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
23735 }
23736
23737 throw new Error("Invalid locale '".concat(options.locale, "'"));
23738}
23739
23740module.exports = exports.default;
23741module.exports.default = exports.default;
23742},{"./alpha":154,"./util/assertString":226,"./util/includes":227,"./util/merge":228}],171:[function(require,module,exports){
23743"use strict";
23744
23745Object.defineProperty(exports, "__esModule", {
23746 value: true
23747});
23748exports.default = isDivisibleBy;
23749
23750var _assertString = _interopRequireDefault(require("./util/assertString"));
23751
23752var _toFloat = _interopRequireDefault(require("./toFloat"));
23753
23754function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23755
23756function isDivisibleBy(str, num) {
23757 (0, _assertString.default)(str);
23758 return (0, _toFloat.default)(str) % parseInt(num, 10) === 0;
23759}
23760
23761module.exports = exports.default;
23762module.exports.default = exports.default;
23763},{"./toFloat":222,"./util/assertString":226}],172:[function(require,module,exports){
23764"use strict";
23765
23766Object.defineProperty(exports, "__esModule", {
23767 value: true
23768});
23769exports.default = isEmail;
23770
23771var _assertString = _interopRequireDefault(require("./util/assertString"));
23772
23773var _merge = _interopRequireDefault(require("./util/merge"));
23774
23775var _isByteLength = _interopRequireDefault(require("./isByteLength"));
23776
23777var _isFQDN = _interopRequireDefault(require("./isFQDN"));
23778
23779var _isIP = _interopRequireDefault(require("./isIP"));
23780
23781function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23782
23783var default_email_options = {
23784 allow_display_name: false,
23785 require_display_name: false,
23786 allow_utf8_local_part: true,
23787 require_tld: true
23788};
23789/* eslint-disable max-len */
23790
23791/* eslint-disable no-control-regex */
23792
23793var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i;
23794var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
23795var gmailUserPart = /^[a-z\d]+$/;
23796var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
23797var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
23798var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
23799/* eslint-enable max-len */
23800
23801/* eslint-enable no-control-regex */
23802
23803function isEmail(str, options) {
23804 (0, _assertString.default)(str);
23805 options = (0, _merge.default)(options, default_email_options);
23806
23807 if (options.require_display_name || options.allow_display_name) {
23808 var display_email = str.match(displayName);
23809
23810 if (display_email) {
23811 str = display_email[1];
23812 } else if (options.require_display_name) {
23813 return false;
23814 }
23815 }
23816
23817 var parts = str.split('@');
23818 var domain = parts.pop();
23819 var user = parts.join('@');
23820 var lower_domain = domain.toLowerCase();
23821
23822 if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
23823 /*
23824 Previously we removed dots for gmail addresses before validating.
23825 This was removed because it allows `multiple..dots@gmail.com`
23826 to be reported as valid, but it is not.
23827 Gmail only normalizes single dots, removing them from here is pointless,
23828 should be done in normalizeEmail
23829 */
23830 user = user.toLowerCase(); // Removing sub-address from username before gmail validation
23831
23832 var username = user.split('+')[0]; // Dots are not included in gmail length restriction
23833
23834 if (!(0, _isByteLength.default)(username.replace('.', ''), {
23835 min: 6,
23836 max: 30
23837 })) {
23838 return false;
23839 }
23840
23841 var _user_parts = username.split('.');
23842
23843 for (var i = 0; i < _user_parts.length; i++) {
23844 if (!gmailUserPart.test(_user_parts[i])) {
23845 return false;
23846 }
23847 }
23848 }
23849
23850 if (!(0, _isByteLength.default)(user, {
23851 max: 64
23852 }) || !(0, _isByteLength.default)(domain, {
23853 max: 254
23854 })) {
23855 return false;
23856 }
23857
23858 if (!(0, _isFQDN.default)(domain, {
23859 require_tld: options.require_tld
23860 })) {
23861 if (!options.allow_ip_domain) {
23862 return false;
23863 }
23864
23865 if (!(0, _isIP.default)(domain)) {
23866 if (!domain.startsWith('[') || !domain.endsWith(']')) {
23867 return false;
23868 }
23869
23870 var noBracketdomain = domain.substr(1, domain.length - 2);
23871
23872 if (noBracketdomain.length === 0 || !(0, _isIP.default)(noBracketdomain)) {
23873 return false;
23874 }
23875 }
23876 }
23877
23878 if (user[0] === '"') {
23879 user = user.slice(1, user.length - 1);
23880 return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
23881 }
23882
23883 var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
23884 var user_parts = user.split('.');
23885
23886 for (var _i = 0; _i < user_parts.length; _i++) {
23887 if (!pattern.test(user_parts[_i])) {
23888 return false;
23889 }
23890 }
23891
23892 return true;
23893}
23894
23895module.exports = exports.default;
23896module.exports.default = exports.default;
23897},{"./isByteLength":166,"./isFQDN":174,"./isIP":181,"./util/assertString":226,"./util/merge":228}],173:[function(require,module,exports){
23898"use strict";
23899
23900Object.defineProperty(exports, "__esModule", {
23901 value: true
23902});
23903exports.default = isEmpty;
23904
23905var _assertString = _interopRequireDefault(require("./util/assertString"));
23906
23907var _merge = _interopRequireDefault(require("./util/merge"));
23908
23909function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23910
23911var default_is_empty_options = {
23912 ignore_whitespace: false
23913};
23914
23915function isEmpty(str, options) {
23916 (0, _assertString.default)(str);
23917 options = (0, _merge.default)(options, default_is_empty_options);
23918 return (options.ignore_whitespace ? str.trim().length : str.length) === 0;
23919}
23920
23921module.exports = exports.default;
23922module.exports.default = exports.default;
23923},{"./util/assertString":226,"./util/merge":228}],174:[function(require,module,exports){
23924"use strict";
23925
23926Object.defineProperty(exports, "__esModule", {
23927 value: true
23928});
23929exports.default = isFQDN;
23930
23931var _assertString = _interopRequireDefault(require("./util/assertString"));
23932
23933var _merge = _interopRequireDefault(require("./util/merge"));
23934
23935function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23936
23937var default_fqdn_options = {
23938 require_tld: true,
23939 allow_underscores: false,
23940 allow_trailing_dot: false
23941};
23942
23943function isFQDN(str, options) {
23944 (0, _assertString.default)(str);
23945 options = (0, _merge.default)(options, default_fqdn_options);
23946 /* Remove the optional trailing dot before checking validity */
23947
23948 if (options.allow_trailing_dot && str[str.length - 1] === '.') {
23949 str = str.substring(0, str.length - 1);
23950 }
23951
23952 var parts = str.split('.');
23953
23954 for (var i = 0; i < parts.length; i++) {
23955 if (parts[i].length > 63) {
23956 return false;
23957 }
23958 }
23959
23960 if (options.require_tld) {
23961 var tld = parts.pop();
23962
23963 if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
23964 return false;
23965 } // disallow spaces
23966
23967
23968 if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) {
23969 return false;
23970 }
23971 }
23972
23973 for (var part, _i = 0; _i < parts.length; _i++) {
23974 part = parts[_i];
23975
23976 if (options.allow_underscores) {
23977 part = part.replace(/_/g, '');
23978 }
23979
23980 if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) {
23981 return false;
23982 } // disallow full-width chars
23983
23984
23985 if (/[\uff01-\uff5e]/.test(part)) {
23986 return false;
23987 }
23988
23989 if (part[0] === '-' || part[part.length - 1] === '-') {
23990 return false;
23991 }
23992 }
23993
23994 return true;
23995}
23996
23997module.exports = exports.default;
23998module.exports.default = exports.default;
23999},{"./util/assertString":226,"./util/merge":228}],175:[function(require,module,exports){
24000"use strict";
24001
24002Object.defineProperty(exports, "__esModule", {
24003 value: true
24004});
24005exports.default = isFloat;
24006exports.locales = void 0;
24007
24008var _assertString = _interopRequireDefault(require("./util/assertString"));
24009
24010var _alpha = require("./alpha");
24011
24012function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24013
24014function isFloat(str, options) {
24015 (0, _assertString.default)(str);
24016 options = options || {};
24017 var float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? _alpha.decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));
24018
24019 if (str === '' || str === '.' || str === '-' || str === '+') {
24020 return false;
24021 }
24022
24023 var value = parseFloat(str.replace(',', '.'));
24024 return float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
24025}
24026
24027var locales = Object.keys(_alpha.decimal);
24028exports.locales = locales;
24029},{"./alpha":154,"./util/assertString":226}],176:[function(require,module,exports){
24030"use strict";
24031
24032Object.defineProperty(exports, "__esModule", {
24033 value: true
24034});
24035exports.default = isFullWidth;
24036exports.fullWidth = void 0;
24037
24038var _assertString = _interopRequireDefault(require("./util/assertString"));
24039
24040function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24041
24042var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
24043exports.fullWidth = fullWidth;
24044
24045function isFullWidth(str) {
24046 (0, _assertString.default)(str);
24047 return fullWidth.test(str);
24048}
24049},{"./util/assertString":226}],177:[function(require,module,exports){
24050"use strict";
24051
24052Object.defineProperty(exports, "__esModule", {
24053 value: true
24054});
24055exports.default = isHalfWidth;
24056exports.halfWidth = void 0;
24057
24058var _assertString = _interopRequireDefault(require("./util/assertString"));
24059
24060function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24061
24062var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
24063exports.halfWidth = halfWidth;
24064
24065function isHalfWidth(str) {
24066 (0, _assertString.default)(str);
24067 return halfWidth.test(str);
24068}
24069},{"./util/assertString":226}],178:[function(require,module,exports){
24070"use strict";
24071
24072Object.defineProperty(exports, "__esModule", {
24073 value: true
24074});
24075exports.default = isHash;
24076
24077var _assertString = _interopRequireDefault(require("./util/assertString"));
24078
24079function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24080
24081var lengths = {
24082 md5: 32,
24083 md4: 32,
24084 sha1: 40,
24085 sha256: 64,
24086 sha384: 96,
24087 sha512: 128,
24088 ripemd128: 32,
24089 ripemd160: 40,
24090 tiger128: 32,
24091 tiger160: 40,
24092 tiger192: 48,
24093 crc32: 8,
24094 crc32b: 8
24095};
24096
24097function isHash(str, algorithm) {
24098 (0, _assertString.default)(str);
24099 var hash = new RegExp("^[a-f0-9]{".concat(lengths[algorithm], "}$"));
24100 return hash.test(str);
24101}
24102
24103module.exports = exports.default;
24104module.exports.default = exports.default;
24105},{"./util/assertString":226}],179:[function(require,module,exports){
24106"use strict";
24107
24108Object.defineProperty(exports, "__esModule", {
24109 value: true
24110});
24111exports.default = isHexColor;
24112
24113var _assertString = _interopRequireDefault(require("./util/assertString"));
24114
24115function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24116
24117var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;
24118
24119function isHexColor(str) {
24120 (0, _assertString.default)(str);
24121 return hexcolor.test(str);
24122}
24123
24124module.exports = exports.default;
24125module.exports.default = exports.default;
24126},{"./util/assertString":226}],180:[function(require,module,exports){
24127"use strict";
24128
24129Object.defineProperty(exports, "__esModule", {
24130 value: true
24131});
24132exports.default = isHexadecimal;
24133
24134var _assertString = _interopRequireDefault(require("./util/assertString"));
24135
24136function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24137
24138var hexadecimal = /^[0-9A-F]+$/i;
24139
24140function isHexadecimal(str) {
24141 (0, _assertString.default)(str);
24142 return hexadecimal.test(str);
24143}
24144
24145module.exports = exports.default;
24146module.exports.default = exports.default;
24147},{"./util/assertString":226}],181:[function(require,module,exports){
24148"use strict";
24149
24150Object.defineProperty(exports, "__esModule", {
24151 value: true
24152});
24153exports.default = isIP;
24154
24155var _assertString = _interopRequireDefault(require("./util/assertString"));
24156
24157function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24158
24159var ipv4Maybe = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
24160var ipv6Block = /^[0-9A-F]{1,4}$/i;
24161
24162function isIP(str) {
24163 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
24164 (0, _assertString.default)(str);
24165 version = String(version);
24166
24167 if (!version) {
24168 return isIP(str, 4) || isIP(str, 6);
24169 } else if (version === '4') {
24170 if (!ipv4Maybe.test(str)) {
24171 return false;
24172 }
24173
24174 var parts = str.split('.').sort(function (a, b) {
24175 return a - b;
24176 });
24177 return parts[3] <= 255;
24178 } else if (version === '6') {
24179 var blocks = str.split(':');
24180 var foundOmissionBlock = false; // marker to indicate ::
24181 // At least some OS accept the last 32 bits of an IPv6 address
24182 // (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says
24183 // that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses,
24184 // and '::a.b.c.d' is deprecated, but also valid.
24185
24186 var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4);
24187 var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8;
24188
24189 if (blocks.length > expectedNumberOfBlocks) {
24190 return false;
24191 } // initial or final ::
24192
24193
24194 if (str === '::') {
24195 return true;
24196 } else if (str.substr(0, 2) === '::') {
24197 blocks.shift();
24198 blocks.shift();
24199 foundOmissionBlock = true;
24200 } else if (str.substr(str.length - 2) === '::') {
24201 blocks.pop();
24202 blocks.pop();
24203 foundOmissionBlock = true;
24204 }
24205
24206 for (var i = 0; i < blocks.length; ++i) {
24207 // test for a :: which can not be at the string start/end
24208 // since those cases have been handled above
24209 if (blocks[i] === '' && i > 0 && i < blocks.length - 1) {
24210 if (foundOmissionBlock) {
24211 return false; // multiple :: in address
24212 }
24213
24214 foundOmissionBlock = true;
24215 } else if (foundIPv4TransitionBlock && i === blocks.length - 1) {// it has been checked before that the last
24216 // block is a valid IPv4 address
24217 } else if (!ipv6Block.test(blocks[i])) {
24218 return false;
24219 }
24220 }
24221
24222 if (foundOmissionBlock) {
24223 return blocks.length >= 1;
24224 }
24225
24226 return blocks.length === expectedNumberOfBlocks;
24227 }
24228
24229 return false;
24230}
24231
24232module.exports = exports.default;
24233module.exports.default = exports.default;
24234},{"./util/assertString":226}],182:[function(require,module,exports){
24235"use strict";
24236
24237Object.defineProperty(exports, "__esModule", {
24238 value: true
24239});
24240exports.default = isIPRange;
24241
24242var _assertString = _interopRequireDefault(require("./util/assertString"));
24243
24244var _isIP = _interopRequireDefault(require("./isIP"));
24245
24246function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24247
24248var subnetMaybe = /^\d{1,2}$/;
24249
24250function isIPRange(str) {
24251 (0, _assertString.default)(str);
24252 var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet
24253
24254 if (parts.length !== 2) {
24255 return false;
24256 }
24257
24258 if (!subnetMaybe.test(parts[1])) {
24259 return false;
24260 } // Disallow preceding 0 i.e. 01, 02, ...
24261
24262
24263 if (parts[1].length > 1 && parts[1].startsWith('0')) {
24264 return false;
24265 }
24266
24267 return (0, _isIP.default)(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0;
24268}
24269
24270module.exports = exports.default;
24271module.exports.default = exports.default;
24272},{"./isIP":181,"./util/assertString":226}],183:[function(require,module,exports){
24273"use strict";
24274
24275Object.defineProperty(exports, "__esModule", {
24276 value: true
24277});
24278exports.default = isISBN;
24279
24280var _assertString = _interopRequireDefault(require("./util/assertString"));
24281
24282function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24283
24284var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
24285var isbn13Maybe = /^(?:[0-9]{13})$/;
24286var factor = [1, 3];
24287
24288function isISBN(str) {
24289 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
24290 (0, _assertString.default)(str);
24291 version = String(version);
24292
24293 if (!version) {
24294 return isISBN(str, 10) || isISBN(str, 13);
24295 }
24296
24297 var sanitized = str.replace(/[\s-]+/g, '');
24298 var checksum = 0;
24299 var i;
24300
24301 if (version === '10') {
24302 if (!isbn10Maybe.test(sanitized)) {
24303 return false;
24304 }
24305
24306 for (i = 0; i < 9; i++) {
24307 checksum += (i + 1) * sanitized.charAt(i);
24308 }
24309
24310 if (sanitized.charAt(9) === 'X') {
24311 checksum += 10 * 10;
24312 } else {
24313 checksum += 10 * sanitized.charAt(9);
24314 }
24315
24316 if (checksum % 11 === 0) {
24317 return !!sanitized;
24318 }
24319 } else if (version === '13') {
24320 if (!isbn13Maybe.test(sanitized)) {
24321 return false;
24322 }
24323
24324 for (i = 0; i < 12; i++) {
24325 checksum += factor[i % 2] * sanitized.charAt(i);
24326 }
24327
24328 if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) {
24329 return !!sanitized;
24330 }
24331 }
24332
24333 return false;
24334}
24335
24336module.exports = exports.default;
24337module.exports.default = exports.default;
24338},{"./util/assertString":226}],184:[function(require,module,exports){
24339"use strict";
24340
24341Object.defineProperty(exports, "__esModule", {
24342 value: true
24343});
24344exports.default = isISIN;
24345
24346var _assertString = _interopRequireDefault(require("./util/assertString"));
24347
24348function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24349
24350var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
24351
24352function isISIN(str) {
24353 (0, _assertString.default)(str);
24354
24355 if (!isin.test(str)) {
24356 return false;
24357 }
24358
24359 var checksumStr = str.replace(/[A-Z]/g, function (character) {
24360 return parseInt(character, 36);
24361 });
24362 var sum = 0;
24363 var digit;
24364 var tmpNum;
24365 var shouldDouble = true;
24366
24367 for (var i = checksumStr.length - 2; i >= 0; i--) {
24368 digit = checksumStr.substring(i, i + 1);
24369 tmpNum = parseInt(digit, 10);
24370
24371 if (shouldDouble) {
24372 tmpNum *= 2;
24373
24374 if (tmpNum >= 10) {
24375 sum += tmpNum + 1;
24376 } else {
24377 sum += tmpNum;
24378 }
24379 } else {
24380 sum += tmpNum;
24381 }
24382
24383 shouldDouble = !shouldDouble;
24384 }
24385
24386 return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
24387}
24388
24389module.exports = exports.default;
24390module.exports.default = exports.default;
24391},{"./util/assertString":226}],185:[function(require,module,exports){
24392"use strict";
24393
24394Object.defineProperty(exports, "__esModule", {
24395 value: true
24396});
24397exports.default = isISO31661Alpha2;
24398
24399var _assertString = _interopRequireDefault(require("./util/assertString"));
24400
24401var _includes = _interopRequireDefault(require("./util/includes"));
24402
24403function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24404
24405// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
24406var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW'];
24407
24408function isISO31661Alpha2(str) {
24409 (0, _assertString.default)(str);
24410 return (0, _includes.default)(validISO31661Alpha2CountriesCodes, str.toUpperCase());
24411}
24412
24413module.exports = exports.default;
24414module.exports.default = exports.default;
24415},{"./util/assertString":226,"./util/includes":227}],186:[function(require,module,exports){
24416"use strict";
24417
24418Object.defineProperty(exports, "__esModule", {
24419 value: true
24420});
24421exports.default = isISO31661Alpha3;
24422
24423var _assertString = _interopRequireDefault(require("./util/assertString"));
24424
24425var _includes = _interopRequireDefault(require("./util/includes"));
24426
24427function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24428
24429// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
24430var validISO31661Alpha3CountriesCodes = ['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE'];
24431
24432function isISO31661Alpha3(str) {
24433 (0, _assertString.default)(str);
24434 return (0, _includes.default)(validISO31661Alpha3CountriesCodes, str.toUpperCase());
24435}
24436
24437module.exports = exports.default;
24438module.exports.default = exports.default;
24439},{"./util/assertString":226,"./util/includes":227}],187:[function(require,module,exports){
24440"use strict";
24441
24442Object.defineProperty(exports, "__esModule", {
24443 value: true
24444});
24445exports.default = isISO8601;
24446
24447var _assertString = _interopRequireDefault(require("./util/assertString"));
24448
24449function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24450
24451/* eslint-disable max-len */
24452// from http://goo.gl/0ejHHW
24453var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
24454/* eslint-enable max-len */
24455
24456var isValidDate = function isValidDate(str) {
24457 // str must have passed the ISO8601 check
24458 // this check is meant to catch invalid dates
24459 // like 2009-02-31
24460 // first check for ordinal dates
24461 var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
24462
24463 if (ordinalMatch) {
24464 var oYear = Number(ordinalMatch[1]);
24465 var oDay = Number(ordinalMatch[2]); // if is leap year
24466
24467 if (oYear % 4 === 0 && oYear % 100 !== 0) return oDay <= 366;
24468 return oDay <= 365;
24469 }
24470
24471 var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
24472 var year = match[1];
24473 var month = match[2];
24474 var day = match[3];
24475 var monthString = month ? "0".concat(month).slice(-2) : month;
24476 var dayString = day ? "0".concat(day).slice(-2) : day; // create a date object and compare
24477
24478 var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
24479 if (isNaN(d.getUTCFullYear())) return false;
24480
24481 if (month && day) {
24482 return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
24483 }
24484
24485 return true;
24486};
24487
24488function isISO8601(str, options) {
24489 (0, _assertString.default)(str);
24490 var check = iso8601.test(str);
24491 if (!options) return check;
24492 if (check && options.strict) return isValidDate(str);
24493 return check;
24494}
24495
24496module.exports = exports.default;
24497module.exports.default = exports.default;
24498},{"./util/assertString":226}],188:[function(require,module,exports){
24499"use strict";
24500
24501Object.defineProperty(exports, "__esModule", {
24502 value: true
24503});
24504exports.default = isISRC;
24505
24506var _assertString = _interopRequireDefault(require("./util/assertString"));
24507
24508function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24509
24510// see http://isrc.ifpi.org/en/isrc-standard/code-syntax
24511var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
24512
24513function isISRC(str) {
24514 (0, _assertString.default)(str);
24515 return isrc.test(str);
24516}
24517
24518module.exports = exports.default;
24519module.exports.default = exports.default;
24520},{"./util/assertString":226}],189:[function(require,module,exports){
24521"use strict";
24522
24523Object.defineProperty(exports, "__esModule", {
24524 value: true
24525});
24526exports.default = isISSN;
24527
24528var _assertString = _interopRequireDefault(require("./util/assertString"));
24529
24530function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24531
24532var issn = '^\\d{4}-?\\d{3}[\\dX]$';
24533
24534function isISSN(str) {
24535 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24536 (0, _assertString.default)(str);
24537 var testIssn = issn;
24538 testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
24539 testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
24540
24541 if (!testIssn.test(str)) {
24542 return false;
24543 }
24544
24545 var digits = str.replace('-', '').toUpperCase();
24546 var checksum = 0;
24547
24548 for (var i = 0; i < digits.length; i++) {
24549 var digit = digits[i];
24550 checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
24551 }
24552
24553 return checksum % 11 === 0;
24554}
24555
24556module.exports = exports.default;
24557module.exports.default = exports.default;
24558},{"./util/assertString":226}],190:[function(require,module,exports){
24559"use strict";
24560
24561Object.defineProperty(exports, "__esModule", {
24562 value: true
24563});
24564exports.default = isIdentityCard;
24565
24566var _assertString = _interopRequireDefault(require("./util/assertString"));
24567
24568function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24569
24570var validators = {
24571 ES: function ES(str) {
24572 (0, _assertString.default)(str);
24573 var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
24574 var charsValue = {
24575 X: 0,
24576 Y: 1,
24577 Z: 2
24578 };
24579 var controlDigits = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E']; // sanitize user input
24580
24581 var sanitized = str.trim().toUpperCase(); // validate the data structure
24582
24583 if (!DNI.test(sanitized)) {
24584 return false;
24585 } // validate the control digit
24586
24587
24588 var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (char) {
24589 return charsValue[char];
24590 });
24591 return sanitized.endsWith(controlDigits[number % 23]);
24592 }
24593};
24594
24595function isIdentityCard(str) {
24596 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'any';
24597 (0, _assertString.default)(str);
24598
24599 if (locale in validators) {
24600 return validators[locale](str);
24601 } else if (locale === 'any') {
24602 for (var key in validators) {
24603 if (validators.hasOwnProperty(key)) {
24604 var validator = validators[key];
24605
24606 if (validator(str)) {
24607 return true;
24608 }
24609 }
24610 }
24611
24612 return false;
24613 }
24614
24615 throw new Error("Invalid locale '".concat(locale, "'"));
24616}
24617
24618module.exports = exports.default;
24619module.exports.default = exports.default;
24620},{"./util/assertString":226}],191:[function(require,module,exports){
24621"use strict";
24622
24623Object.defineProperty(exports, "__esModule", {
24624 value: true
24625});
24626exports.default = isIn;
24627
24628var _assertString = _interopRequireDefault(require("./util/assertString"));
24629
24630var _toString = _interopRequireDefault(require("./util/toString"));
24631
24632function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24633
24634function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
24635
24636function isIn(str, options) {
24637 (0, _assertString.default)(str);
24638 var i;
24639
24640 if (Object.prototype.toString.call(options) === '[object Array]') {
24641 var array = [];
24642
24643 for (i in options) {
24644 if ({}.hasOwnProperty.call(options, i)) {
24645 array[i] = (0, _toString.default)(options[i]);
24646 }
24647 }
24648
24649 return array.indexOf(str) >= 0;
24650 } else if (_typeof(options) === 'object') {
24651 return options.hasOwnProperty(str);
24652 } else if (options && typeof options.indexOf === 'function') {
24653 return options.indexOf(str) >= 0;
24654 }
24655
24656 return false;
24657}
24658
24659module.exports = exports.default;
24660module.exports.default = exports.default;
24661},{"./util/assertString":226,"./util/toString":229}],192:[function(require,module,exports){
24662"use strict";
24663
24664Object.defineProperty(exports, "__esModule", {
24665 value: true
24666});
24667exports.default = isInt;
24668
24669var _assertString = _interopRequireDefault(require("./util/assertString"));
24670
24671function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24672
24673var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
24674var intLeadingZeroes = /^[-+]?[0-9]+$/;
24675
24676function isInt(str, options) {
24677 (0, _assertString.default)(str);
24678 options = options || {}; // Get the regex to use for testing, based on whether
24679 // leading zeroes are allowed or not.
24680
24681 var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? int : intLeadingZeroes; // Check min/max/lt/gt
24682
24683 var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min;
24684 var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max;
24685 var ltCheckPassed = !options.hasOwnProperty('lt') || str < options.lt;
24686 var gtCheckPassed = !options.hasOwnProperty('gt') || str > options.gt;
24687 return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
24688}
24689
24690module.exports = exports.default;
24691module.exports.default = exports.default;
24692},{"./util/assertString":226}],193:[function(require,module,exports){
24693"use strict";
24694
24695Object.defineProperty(exports, "__esModule", {
24696 value: true
24697});
24698exports.default = isJSON;
24699
24700var _assertString = _interopRequireDefault(require("./util/assertString"));
24701
24702function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24703
24704function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
24705
24706function isJSON(str) {
24707 (0, _assertString.default)(str);
24708
24709 try {
24710 var obj = JSON.parse(str);
24711 return !!obj && _typeof(obj) === 'object';
24712 } catch (e) {
24713 /* ignore */
24714 }
24715
24716 return false;
24717}
24718
24719module.exports = exports.default;
24720module.exports.default = exports.default;
24721},{"./util/assertString":226}],194:[function(require,module,exports){
24722"use strict";
24723
24724Object.defineProperty(exports, "__esModule", {
24725 value: true
24726});
24727exports.default = isJWT;
24728
24729var _assertString = _interopRequireDefault(require("./util/assertString"));
24730
24731function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24732
24733var jwt = /^([A-Za-z0-9\-_~+\/]+[=]{0,2})\.([A-Za-z0-9\-_~+\/]+[=]{0,2})(?:\.([A-Za-z0-9\-_~+\/]+[=]{0,2}))?$/;
24734
24735function isJWT(str) {
24736 (0, _assertString.default)(str);
24737 return jwt.test(str);
24738}
24739
24740module.exports = exports.default;
24741module.exports.default = exports.default;
24742},{"./util/assertString":226}],195:[function(require,module,exports){
24743"use strict";
24744
24745Object.defineProperty(exports, "__esModule", {
24746 value: true
24747});
24748exports.default = _default;
24749
24750var _assertString = _interopRequireDefault(require("./util/assertString"));
24751
24752function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24753
24754var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
24755var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
24756
24757function _default(str) {
24758 (0, _assertString.default)(str);
24759 if (!str.includes(',')) return false;
24760 var pair = str.split(',');
24761 return lat.test(pair[0]) && long.test(pair[1]);
24762}
24763
24764module.exports = exports.default;
24765module.exports.default = exports.default;
24766},{"./util/assertString":226}],196:[function(require,module,exports){
24767"use strict";
24768
24769Object.defineProperty(exports, "__esModule", {
24770 value: true
24771});
24772exports.default = isLength;
24773
24774var _assertString = _interopRequireDefault(require("./util/assertString"));
24775
24776function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24777
24778function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
24779
24780/* eslint-disable prefer-rest-params */
24781function isLength(str, options) {
24782 (0, _assertString.default)(str);
24783 var min;
24784 var max;
24785
24786 if (_typeof(options) === 'object') {
24787 min = options.min || 0;
24788 max = options.max;
24789 } else {
24790 // backwards compatibility: isLength(str, min [, max])
24791 min = arguments[1];
24792 max = arguments[2];
24793 }
24794
24795 var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
24796 var len = str.length - surrogatePairs.length;
24797 return len >= min && (typeof max === 'undefined' || len <= max);
24798}
24799
24800module.exports = exports.default;
24801module.exports.default = exports.default;
24802},{"./util/assertString":226}],197:[function(require,module,exports){
24803"use strict";
24804
24805Object.defineProperty(exports, "__esModule", {
24806 value: true
24807});
24808exports.default = isLowercase;
24809
24810var _assertString = _interopRequireDefault(require("./util/assertString"));
24811
24812function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24813
24814function isLowercase(str) {
24815 (0, _assertString.default)(str);
24816 return str === str.toLowerCase();
24817}
24818
24819module.exports = exports.default;
24820module.exports.default = exports.default;
24821},{"./util/assertString":226}],198:[function(require,module,exports){
24822"use strict";
24823
24824Object.defineProperty(exports, "__esModule", {
24825 value: true
24826});
24827exports.default = isMACAddress;
24828
24829var _assertString = _interopRequireDefault(require("./util/assertString"));
24830
24831function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24832
24833var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
24834var macAddressNoColons = /^([0-9a-fA-F]){12}$/;
24835
24836function isMACAddress(str, options) {
24837 (0, _assertString.default)(str);
24838
24839 if (options && options.no_colons) {
24840 return macAddressNoColons.test(str);
24841 }
24842
24843 return macAddress.test(str);
24844}
24845
24846module.exports = exports.default;
24847module.exports.default = exports.default;
24848},{"./util/assertString":226}],199:[function(require,module,exports){
24849"use strict";
24850
24851Object.defineProperty(exports, "__esModule", {
24852 value: true
24853});
24854exports.default = isMD5;
24855
24856var _assertString = _interopRequireDefault(require("./util/assertString"));
24857
24858function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24859
24860var md5 = /^[a-f0-9]{32}$/;
24861
24862function isMD5(str) {
24863 (0, _assertString.default)(str);
24864 return md5.test(str);
24865}
24866
24867module.exports = exports.default;
24868module.exports.default = exports.default;
24869},{"./util/assertString":226}],200:[function(require,module,exports){
24870"use strict";
24871
24872Object.defineProperty(exports, "__esModule", {
24873 value: true
24874});
24875exports.default = isMagnetURI;
24876
24877var _assertString = _interopRequireDefault(require("./util/assertString"));
24878
24879function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24880
24881var magnetURI = /^magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}&dn=.+&tr=.+$/i;
24882
24883function isMagnetURI(url) {
24884 (0, _assertString.default)(url);
24885 return magnetURI.test(url.trim());
24886}
24887
24888module.exports = exports.default;
24889module.exports.default = exports.default;
24890},{"./util/assertString":226}],201:[function(require,module,exports){
24891"use strict";
24892
24893Object.defineProperty(exports, "__esModule", {
24894 value: true
24895});
24896exports.default = isMimeType;
24897
24898var _assertString = _interopRequireDefault(require("./util/assertString"));
24899
24900function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24901
24902/*
24903 Checks if the provided string matches to a correct Media type format (MIME type)
24904
24905 This function only checks is the string format follows the
24906 etablished rules by the according RFC specifications.
24907 This function supports 'charset' in textual media types
24908 (https://tools.ietf.org/html/rfc6657).
24909
24910 This function does not check against all the media types listed
24911 by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
24912 because of lightness purposes : it would require to include
24913 all these MIME types in this librairy, which would weigh it
24914 significantly. This kind of effort maybe is not worth for the use that
24915 this function has in this entire librairy.
24916
24917 More informations in the RFC specifications :
24918 - https://tools.ietf.org/html/rfc2045
24919 - https://tools.ietf.org/html/rfc2046
24920 - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
24921 - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
24922*/
24923// Match simple MIME types
24924// NB :
24925// Subtype length must not exceed 100 characters.
24926// This rule does not comply to the RFC specs (what is the max length ?).
24927var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len
24928// Handle "charset" in "text/*"
24929
24930var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len
24931// Handle "boundary" in "multipart/*"
24932
24933var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
24934
24935function isMimeType(str) {
24936 (0, _assertString.default)(str);
24937 return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
24938}
24939
24940module.exports = exports.default;
24941module.exports.default = exports.default;
24942},{"./util/assertString":226}],202:[function(require,module,exports){
24943"use strict";
24944
24945Object.defineProperty(exports, "__esModule", {
24946 value: true
24947});
24948exports.default = isMobilePhone;
24949exports.locales = void 0;
24950
24951var _assertString = _interopRequireDefault(require("./util/assertString"));
24952
24953function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24954
24955/* eslint-disable max-len */
24956var phones = {
24957 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
24958 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
24959 'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/,
24960 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
24961 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
24962 'ar-KW': /^(\+?965)[569]\d{7}$/,
24963 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
24964 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
24965 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
24966 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
24967 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
24968 'bn-BD': /\+?(88)?0?1[356789][0-9]{8}\b/,
24969 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
24970 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
24971 'de-DE': /^(\+49)?0?1(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
24972 'el-GR': /^(\+?30|0)?(69\d{8})$/,
24973 'en-AU': /^(\+?61|0)4\d{8}$/,
24974 'en-GB': /^(\+?44|0)7\d{9}$/,
24975 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
24976 'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
24977 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
24978 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
24979 'en-KE': /^(\+?254|0)?[7]\d{8}$/,
24980 'en-MU': /^(\+?230|0)?\d{8}$/,
24981 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
24982 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
24983 'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
24984 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
24985 'en-SG': /^(\+65)?[89]\d{7}$/,
24986 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
24987 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
24988 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
24989 'en-ZA': /^(\+?27|0)\d{9}$/,
24990 'en-ZM': /^(\+?26)?09[567]\d{7}$/,
24991 'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
24992 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
24993 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
24994 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
24995 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
24996 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
24997 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
24998 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
24999 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
25000 'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
25001 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
25002 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
25003 'ja-JP': /^(\+?81|0)[789]0[ \-]?[1-9]\d{2}[ \-]?\d{5}$/,
25004 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
25005 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
25006 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
25007 'lt-LT': /^(\+370|8)\d{8}$/,
25008 'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
25009 'nb-NO': /^(\+?47)?[49]\d{7}$/,
25010 'nl-BE': /^(\+?32|0)4?\d{8}$/,
25011 'nn-NO': /^(\+?47)?[49]\d{7}$/,
25012 'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
25013 'pt-BR': /(?=^(\+?5{2}\-?|0)[1-9]{2}\-?\d{4}\-?\d{4}$)(^(\+?5{2}\-?|0)[1-9]{2}\-?[6-9]{1}\d{3}\-?\d{4}$)|(^(\+?5{2}\-?|0)[1-9]{2}\-?9[6-9]{1}\d{3}\-?\d{4}$)/,
25014 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
25015 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
25016 'ru-RU': /^(\+?7|8)?9\d{9}$/,
25017 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
25018 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
25019 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
25020 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
25021 'th-TH': /^(\+66|66|0)\d{9}$/,
25022 'tr-TR': /^(\+?90|0)?5\d{9}$/,
25023 'uk-UA': /^(\+?38|8)?0\d{9}$/,
25024 'vi-VN': /^(\+?84|0)((3([2-9]))|(5([689]))|(7([0|6-9]))|(8([1-5]))|(9([0-9])))([0-9]{7})$/,
25025 'zh-CN': /^((\+|00)86)?1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/,
25026 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
25027};
25028/* eslint-enable max-len */
25029// aliases
25030
25031phones['en-CA'] = phones['en-US'];
25032phones['fr-BE'] = phones['nl-BE'];
25033phones['zh-HK'] = phones['en-HK'];
25034
25035function isMobilePhone(str, locale, options) {
25036 (0, _assertString.default)(str);
25037
25038 if (options && options.strictMode && !str.startsWith('+')) {
25039 return false;
25040 }
25041
25042 if (Array.isArray(locale)) {
25043 return locale.some(function (key) {
25044 if (phones.hasOwnProperty(key)) {
25045 var phone = phones[key];
25046
25047 if (phone.test(str)) {
25048 return true;
25049 }
25050 }
25051
25052 return false;
25053 });
25054 } else if (locale in phones) {
25055 return phones[locale].test(str); // alias falsey locale as 'any'
25056 } else if (!locale || locale === 'any') {
25057 for (var key in phones) {
25058 if (phones.hasOwnProperty(key)) {
25059 var phone = phones[key];
25060
25061 if (phone.test(str)) {
25062 return true;
25063 }
25064 }
25065 }
25066
25067 return false;
25068 }
25069
25070 throw new Error("Invalid locale '".concat(locale, "'"));
25071}
25072
25073var locales = Object.keys(phones);
25074exports.locales = locales;
25075},{"./util/assertString":226}],203:[function(require,module,exports){
25076"use strict";
25077
25078Object.defineProperty(exports, "__esModule", {
25079 value: true
25080});
25081exports.default = isMongoId;
25082
25083var _assertString = _interopRequireDefault(require("./util/assertString"));
25084
25085var _isHexadecimal = _interopRequireDefault(require("./isHexadecimal"));
25086
25087function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25088
25089function isMongoId(str) {
25090 (0, _assertString.default)(str);
25091 return (0, _isHexadecimal.default)(str) && str.length === 24;
25092}
25093
25094module.exports = exports.default;
25095module.exports.default = exports.default;
25096},{"./isHexadecimal":180,"./util/assertString":226}],204:[function(require,module,exports){
25097"use strict";
25098
25099Object.defineProperty(exports, "__esModule", {
25100 value: true
25101});
25102exports.default = isMultibyte;
25103
25104var _assertString = _interopRequireDefault(require("./util/assertString"));
25105
25106function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25107
25108/* eslint-disable no-control-regex */
25109var multibyte = /[^\x00-\x7F]/;
25110/* eslint-enable no-control-regex */
25111
25112function isMultibyte(str) {
25113 (0, _assertString.default)(str);
25114 return multibyte.test(str);
25115}
25116
25117module.exports = exports.default;
25118module.exports.default = exports.default;
25119},{"./util/assertString":226}],205:[function(require,module,exports){
25120"use strict";
25121
25122Object.defineProperty(exports, "__esModule", {
25123 value: true
25124});
25125exports.default = isNumeric;
25126
25127var _assertString = _interopRequireDefault(require("./util/assertString"));
25128
25129function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25130
25131var numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;
25132var numericNoSymbols = /^[0-9]+$/;
25133
25134function isNumeric(str, options) {
25135 (0, _assertString.default)(str);
25136
25137 if (options && options.no_symbols) {
25138 return numericNoSymbols.test(str);
25139 }
25140
25141 return numeric.test(str);
25142}
25143
25144module.exports = exports.default;
25145module.exports.default = exports.default;
25146},{"./util/assertString":226}],206:[function(require,module,exports){
25147"use strict";
25148
25149Object.defineProperty(exports, "__esModule", {
25150 value: true
25151});
25152exports.default = isPort;
25153
25154var _isInt = _interopRequireDefault(require("./isInt"));
25155
25156function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25157
25158function isPort(str) {
25159 return (0, _isInt.default)(str, {
25160 min: 0,
25161 max: 65535
25162 });
25163}
25164
25165module.exports = exports.default;
25166module.exports.default = exports.default;
25167},{"./isInt":192}],207:[function(require,module,exports){
25168"use strict";
25169
25170Object.defineProperty(exports, "__esModule", {
25171 value: true
25172});
25173exports.default = _default;
25174exports.locales = void 0;
25175
25176var _assertString = _interopRequireDefault(require("./util/assertString"));
25177
25178function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25179
25180// common patterns
25181var threeDigit = /^\d{3}$/;
25182var fourDigit = /^\d{4}$/;
25183var fiveDigit = /^\d{5}$/;
25184var sixDigit = /^\d{6}$/;
25185var patterns = {
25186 AD: /^AD\d{3}$/,
25187 AT: fourDigit,
25188 AU: fourDigit,
25189 BE: fourDigit,
25190 BG: fourDigit,
25191 CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
25192 CH: fourDigit,
25193 CZ: /^\d{3}\s?\d{2}$/,
25194 DE: fiveDigit,
25195 DK: fourDigit,
25196 DZ: fiveDigit,
25197 EE: fiveDigit,
25198 ES: fiveDigit,
25199 FI: fiveDigit,
25200 FR: /^\d{2}\s?\d{3}$/,
25201 GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
25202 GR: /^\d{3}\s?\d{2}$/,
25203 HR: /^([1-5]\d{4}$)/,
25204 HU: fourDigit,
25205 IL: fiveDigit,
25206 IN: sixDigit,
25207 IS: threeDigit,
25208 IT: fiveDigit,
25209 JP: /^\d{3}\-\d{4}$/,
25210 KE: fiveDigit,
25211 LI: /^(948[5-9]|949[0-7])$/,
25212 LT: /^LT\-\d{5}$/,
25213 LU: fourDigit,
25214 LV: /^LV\-\d{4}$/,
25215 MX: fiveDigit,
25216 NL: /^\d{4}\s?[a-z]{2}$/i,
25217 NO: fourDigit,
25218 PL: /^\d{2}\-\d{3}$/,
25219 PT: /^\d{4}\-\d{3}?$/,
25220 RO: sixDigit,
25221 RU: sixDigit,
25222 SA: fiveDigit,
25223 SE: /^\d{3}\s?\d{2}$/,
25224 SI: fourDigit,
25225 SK: /^\d{3}\s?\d{2}$/,
25226 TN: fourDigit,
25227 TW: /^\d{3}(\d{2})?$/,
25228 UA: fiveDigit,
25229 US: /^\d{5}(-\d{4})?$/,
25230 ZA: fourDigit,
25231 ZM: fiveDigit
25232};
25233var locales = Object.keys(patterns);
25234exports.locales = locales;
25235
25236function _default(str, locale) {
25237 (0, _assertString.default)(str);
25238
25239 if (locale in patterns) {
25240 return patterns[locale].test(str);
25241 } else if (locale === 'any') {
25242 for (var key in patterns) {
25243 if (patterns.hasOwnProperty(key)) {
25244 var pattern = patterns[key];
25245
25246 if (pattern.test(str)) {
25247 return true;
25248 }
25249 }
25250 }
25251
25252 return false;
25253 }
25254
25255 throw new Error("Invalid locale '".concat(locale, "'"));
25256}
25257},{"./util/assertString":226}],208:[function(require,module,exports){
25258"use strict";
25259
25260Object.defineProperty(exports, "__esModule", {
25261 value: true
25262});
25263exports.default = isRFC3339;
25264
25265var _assertString = _interopRequireDefault(require("./util/assertString"));
25266
25267function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25268
25269/* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
25270var dateFullYear = /[0-9]{4}/;
25271var dateMonth = /(0[1-9]|1[0-2])/;
25272var dateMDay = /([12]\d|0[1-9]|3[01])/;
25273var timeHour = /([01][0-9]|2[0-3])/;
25274var timeMinute = /[0-5][0-9]/;
25275var timeSecond = /([0-5][0-9]|60)/;
25276var timeSecFrac = /(\.[0-9]+)?/;
25277var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
25278var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
25279var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
25280var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
25281var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
25282var rfc3339 = new RegExp("".concat(fullDate.source, "[ tT]").concat(fullTime.source));
25283
25284function isRFC3339(str) {
25285 (0, _assertString.default)(str);
25286 return rfc3339.test(str);
25287}
25288
25289module.exports = exports.default;
25290module.exports.default = exports.default;
25291},{"./util/assertString":226}],209:[function(require,module,exports){
25292"use strict";
25293
25294Object.defineProperty(exports, "__esModule", {
25295 value: true
25296});
25297exports.default = isSurrogatePair;
25298
25299var _assertString = _interopRequireDefault(require("./util/assertString"));
25300
25301function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25302
25303var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
25304
25305function isSurrogatePair(str) {
25306 (0, _assertString.default)(str);
25307 return surrogatePair.test(str);
25308}
25309
25310module.exports = exports.default;
25311module.exports.default = exports.default;
25312},{"./util/assertString":226}],210:[function(require,module,exports){
25313"use strict";
25314
25315Object.defineProperty(exports, "__esModule", {
25316 value: true
25317});
25318exports.default = isURL;
25319
25320var _assertString = _interopRequireDefault(require("./util/assertString"));
25321
25322var _isFQDN = _interopRequireDefault(require("./isFQDN"));
25323
25324var _isIP = _interopRequireDefault(require("./isIP"));
25325
25326var _merge = _interopRequireDefault(require("./util/merge"));
25327
25328function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25329
25330var default_url_options = {
25331 protocols: ['http', 'https', 'ftp'],
25332 require_tld: true,
25333 require_protocol: false,
25334 require_host: true,
25335 require_valid_protocol: true,
25336 allow_underscores: false,
25337 allow_trailing_dot: false,
25338 allow_protocol_relative_urls: false
25339};
25340var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
25341
25342function isRegExp(obj) {
25343 return Object.prototype.toString.call(obj) === '[object RegExp]';
25344}
25345
25346function checkHost(host, matches) {
25347 for (var i = 0; i < matches.length; i++) {
25348 var match = matches[i];
25349
25350 if (host === match || isRegExp(match) && match.test(host)) {
25351 return true;
25352 }
25353 }
25354
25355 return false;
25356}
25357
25358function isURL(url, options) {
25359 (0, _assertString.default)(url);
25360
25361 if (!url || url.length >= 2083 || /[\s<>]/.test(url)) {
25362 return false;
25363 }
25364
25365 if (url.indexOf('mailto:') === 0) {
25366 return false;
25367 }
25368
25369 options = (0, _merge.default)(options, default_url_options);
25370 var protocol, auth, host, hostname, port, port_str, split, ipv6;
25371 split = url.split('#');
25372 url = split.shift();
25373 split = url.split('?');
25374 url = split.shift();
25375 split = url.split('://');
25376
25377 if (split.length > 1) {
25378 protocol = split.shift().toLowerCase();
25379
25380 if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
25381 return false;
25382 }
25383 } else if (options.require_protocol) {
25384 return false;
25385 } else if (url.substr(0, 2) === '//') {
25386 if (!options.allow_protocol_relative_urls) {
25387 return false;
25388 }
25389
25390 split[0] = url.substr(2);
25391 }
25392
25393 url = split.join('://');
25394
25395 if (url === '') {
25396 return false;
25397 }
25398
25399 split = url.split('/');
25400 url = split.shift();
25401
25402 if (url === '' && !options.require_host) {
25403 return true;
25404 }
25405
25406 split = url.split('@');
25407
25408 if (split.length > 1) {
25409 if (options.disallow_auth) {
25410 return false;
25411 }
25412
25413 auth = split.shift();
25414
25415 if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
25416 return false;
25417 }
25418 }
25419
25420 hostname = split.join('@');
25421 port_str = null;
25422 ipv6 = null;
25423 var ipv6_match = hostname.match(wrapped_ipv6);
25424
25425 if (ipv6_match) {
25426 host = '';
25427 ipv6 = ipv6_match[1];
25428 port_str = ipv6_match[2] || null;
25429 } else {
25430 split = hostname.split(':');
25431 host = split.shift();
25432
25433 if (split.length) {
25434 port_str = split.join(':');
25435 }
25436 }
25437
25438 if (port_str !== null) {
25439 port = parseInt(port_str, 10);
25440
25441 if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
25442 return false;
25443 }
25444 }
25445
25446 if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) {
25447 return false;
25448 }
25449
25450 host = host || ipv6;
25451
25452 if (options.host_whitelist && !checkHost(host, options.host_whitelist)) {
25453 return false;
25454 }
25455
25456 if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
25457 return false;
25458 }
25459
25460 return true;
25461}
25462
25463module.exports = exports.default;
25464module.exports.default = exports.default;
25465},{"./isFQDN":174,"./isIP":181,"./util/assertString":226,"./util/merge":228}],211:[function(require,module,exports){
25466"use strict";
25467
25468Object.defineProperty(exports, "__esModule", {
25469 value: true
25470});
25471exports.default = isUUID;
25472
25473var _assertString = _interopRequireDefault(require("./util/assertString"));
25474
25475function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25476
25477var uuid = {
25478 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
25479 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
25480 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
25481 all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
25482};
25483
25484function isUUID(str) {
25485 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'all';
25486 (0, _assertString.default)(str);
25487 var pattern = uuid[version];
25488 return pattern && pattern.test(str);
25489}
25490
25491module.exports = exports.default;
25492module.exports.default = exports.default;
25493},{"./util/assertString":226}],212:[function(require,module,exports){
25494"use strict";
25495
25496Object.defineProperty(exports, "__esModule", {
25497 value: true
25498});
25499exports.default = isUppercase;
25500
25501var _assertString = _interopRequireDefault(require("./util/assertString"));
25502
25503function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25504
25505function isUppercase(str) {
25506 (0, _assertString.default)(str);
25507 return str === str.toUpperCase();
25508}
25509
25510module.exports = exports.default;
25511module.exports.default = exports.default;
25512},{"./util/assertString":226}],213:[function(require,module,exports){
25513"use strict";
25514
25515Object.defineProperty(exports, "__esModule", {
25516 value: true
25517});
25518exports.default = isVariableWidth;
25519
25520var _assertString = _interopRequireDefault(require("./util/assertString"));
25521
25522var _isFullWidth = require("./isFullWidth");
25523
25524var _isHalfWidth = require("./isHalfWidth");
25525
25526function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25527
25528function isVariableWidth(str) {
25529 (0, _assertString.default)(str);
25530 return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
25531}
25532
25533module.exports = exports.default;
25534module.exports.default = exports.default;
25535},{"./isFullWidth":176,"./isHalfWidth":177,"./util/assertString":226}],214:[function(require,module,exports){
25536"use strict";
25537
25538Object.defineProperty(exports, "__esModule", {
25539 value: true
25540});
25541exports.default = isWhitelisted;
25542
25543var _assertString = _interopRequireDefault(require("./util/assertString"));
25544
25545function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25546
25547function isWhitelisted(str, chars) {
25548 (0, _assertString.default)(str);
25549
25550 for (var i = str.length - 1; i >= 0; i--) {
25551 if (chars.indexOf(str[i]) === -1) {
25552 return false;
25553 }
25554 }
25555
25556 return true;
25557}
25558
25559module.exports = exports.default;
25560module.exports.default = exports.default;
25561},{"./util/assertString":226}],215:[function(require,module,exports){
25562"use strict";
25563
25564Object.defineProperty(exports, "__esModule", {
25565 value: true
25566});
25567exports.default = ltrim;
25568
25569var _assertString = _interopRequireDefault(require("./util/assertString"));
25570
25571function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25572
25573function ltrim(str, chars) {
25574 (0, _assertString.default)(str);
25575 var pattern = chars ? new RegExp("^[".concat(chars, "]+"), 'g') : /^\s+/g;
25576 return str.replace(pattern, '');
25577}
25578
25579module.exports = exports.default;
25580module.exports.default = exports.default;
25581},{"./util/assertString":226}],216:[function(require,module,exports){
25582"use strict";
25583
25584Object.defineProperty(exports, "__esModule", {
25585 value: true
25586});
25587exports.default = matches;
25588
25589var _assertString = _interopRequireDefault(require("./util/assertString"));
25590
25591function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25592
25593function matches(str, pattern, modifiers) {
25594 (0, _assertString.default)(str);
25595
25596 if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
25597 pattern = new RegExp(pattern, modifiers);
25598 }
25599
25600 return pattern.test(str);
25601}
25602
25603module.exports = exports.default;
25604module.exports.default = exports.default;
25605},{"./util/assertString":226}],217:[function(require,module,exports){
25606"use strict";
25607
25608Object.defineProperty(exports, "__esModule", {
25609 value: true
25610});
25611exports.default = normalizeEmail;
25612
25613var _merge = _interopRequireDefault(require("./util/merge"));
25614
25615function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25616
25617var default_normalize_email_options = {
25618 // The following options apply to all email addresses
25619 // Lowercases the local part of the email address.
25620 // Please note this may violate RFC 5321 as per http://stackoverflow.com/a/9808332/192024).
25621 // The domain is always lowercased, as per RFC 1035
25622 all_lowercase: true,
25623 // The following conversions are specific to GMail
25624 // Lowercases the local part of the GMail address (known to be case-insensitive)
25625 gmail_lowercase: true,
25626 // Removes dots from the local part of the email address, as that's ignored by GMail
25627 gmail_remove_dots: true,
25628 // Removes the subaddress (e.g. "+foo") from the email address
25629 gmail_remove_subaddress: true,
25630 // Conversts the googlemail.com domain to gmail.com
25631 gmail_convert_googlemaildotcom: true,
25632 // The following conversions are specific to Outlook.com / Windows Live / Hotmail
25633 // Lowercases the local part of the Outlook.com address (known to be case-insensitive)
25634 outlookdotcom_lowercase: true,
25635 // Removes the subaddress (e.g. "+foo") from the email address
25636 outlookdotcom_remove_subaddress: true,
25637 // The following conversions are specific to Yahoo
25638 // Lowercases the local part of the Yahoo address (known to be case-insensitive)
25639 yahoo_lowercase: true,
25640 // Removes the subaddress (e.g. "-foo") from the email address
25641 yahoo_remove_subaddress: true,
25642 // The following conversions are specific to Yandex
25643 // Lowercases the local part of the Yandex address (known to be case-insensitive)
25644 yandex_lowercase: true,
25645 // The following conversions are specific to iCloud
25646 // Lowercases the local part of the iCloud address (known to be case-insensitive)
25647 icloud_lowercase: true,
25648 // Removes the subaddress (e.g. "+foo") from the email address
25649 icloud_remove_subaddress: true
25650}; // List of domains used by iCloud
25651
25652var icloud_domains = ['icloud.com', 'me.com']; // List of domains used by Outlook.com and its predecessors
25653// This list is likely incomplete.
25654// Partial reference:
25655// https://blogs.office.com/2013/04/17/outlook-com-gets-two-step-verification-sign-in-by-alias-and-new-international-domains/
25656
25657var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.cl', 'hotmail.co.il', 'hotmail.co.nz', 'hotmail.co.th', 'hotmail.co.uk', 'hotmail.com', 'hotmail.com.ar', 'hotmail.com.au', 'hotmail.com.br', 'hotmail.com.gr', 'hotmail.com.mx', 'hotmail.com.pe', 'hotmail.com.tr', 'hotmail.com.vn', 'hotmail.cz', 'hotmail.de', 'hotmail.dk', 'hotmail.es', 'hotmail.fr', 'hotmail.hu', 'hotmail.id', 'hotmail.ie', 'hotmail.in', 'hotmail.it', 'hotmail.jp', 'hotmail.kr', 'hotmail.lv', 'hotmail.my', 'hotmail.ph', 'hotmail.pt', 'hotmail.sa', 'hotmail.sg', 'hotmail.sk', 'live.be', 'live.co.uk', 'live.com', 'live.com.ar', 'live.com.mx', 'live.de', 'live.es', 'live.eu', 'live.fr', 'live.it', 'live.nl', 'msn.com', 'outlook.at', 'outlook.be', 'outlook.cl', 'outlook.co.il', 'outlook.co.nz', 'outlook.co.th', 'outlook.com', 'outlook.com.ar', 'outlook.com.au', 'outlook.com.br', 'outlook.com.gr', 'outlook.com.pe', 'outlook.com.tr', 'outlook.com.vn', 'outlook.cz', 'outlook.de', 'outlook.dk', 'outlook.es', 'outlook.fr', 'outlook.hu', 'outlook.id', 'outlook.ie', 'outlook.in', 'outlook.it', 'outlook.jp', 'outlook.kr', 'outlook.lv', 'outlook.my', 'outlook.ph', 'outlook.pt', 'outlook.sa', 'outlook.sg', 'outlook.sk', 'passport.com']; // List of domains used by Yahoo Mail
25658// This list is likely incomplete
25659
25660var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com']; // List of domains used by yandex.ru
25661
25662var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru']; // replace single dots, but not multiple consecutive dots
25663
25664function dotsReplacer(match) {
25665 if (match.length > 1) {
25666 return match;
25667 }
25668
25669 return '';
25670}
25671
25672function normalizeEmail(email, options) {
25673 options = (0, _merge.default)(options, default_normalize_email_options);
25674 var raw_parts = email.split('@');
25675 var domain = raw_parts.pop();
25676 var user = raw_parts.join('@');
25677 var parts = [user, domain]; // The domain is always lowercased, as it's case-insensitive per RFC 1035
25678
25679 parts[1] = parts[1].toLowerCase();
25680
25681 if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
25682 // Address is GMail
25683 if (options.gmail_remove_subaddress) {
25684 parts[0] = parts[0].split('+')[0];
25685 }
25686
25687 if (options.gmail_remove_dots) {
25688 // this does not replace consecutive dots like example..email@gmail.com
25689 parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
25690 }
25691
25692 if (!parts[0].length) {
25693 return false;
25694 }
25695
25696 if (options.all_lowercase || options.gmail_lowercase) {
25697 parts[0] = parts[0].toLowerCase();
25698 }
25699
25700 parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
25701 } else if (icloud_domains.indexOf(parts[1]) >= 0) {
25702 // Address is iCloud
25703 if (options.icloud_remove_subaddress) {
25704 parts[0] = parts[0].split('+')[0];
25705 }
25706
25707 if (!parts[0].length) {
25708 return false;
25709 }
25710
25711 if (options.all_lowercase || options.icloud_lowercase) {
25712 parts[0] = parts[0].toLowerCase();
25713 }
25714 } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
25715 // Address is Outlook.com
25716 if (options.outlookdotcom_remove_subaddress) {
25717 parts[0] = parts[0].split('+')[0];
25718 }
25719
25720 if (!parts[0].length) {
25721 return false;
25722 }
25723
25724 if (options.all_lowercase || options.outlookdotcom_lowercase) {
25725 parts[0] = parts[0].toLowerCase();
25726 }
25727 } else if (yahoo_domains.indexOf(parts[1]) >= 0) {
25728 // Address is Yahoo
25729 if (options.yahoo_remove_subaddress) {
25730 var components = parts[0].split('-');
25731 parts[0] = components.length > 1 ? components.slice(0, -1).join('-') : components[0];
25732 }
25733
25734 if (!parts[0].length) {
25735 return false;
25736 }
25737
25738 if (options.all_lowercase || options.yahoo_lowercase) {
25739 parts[0] = parts[0].toLowerCase();
25740 }
25741 } else if (yandex_domains.indexOf(parts[1]) >= 0) {
25742 if (options.all_lowercase || options.yandex_lowercase) {
25743 parts[0] = parts[0].toLowerCase();
25744 }
25745
25746 parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
25747 } else if (options.all_lowercase) {
25748 // Any other address
25749 parts[0] = parts[0].toLowerCase();
25750 }
25751
25752 return parts.join('@');
25753}
25754
25755module.exports = exports.default;
25756module.exports.default = exports.default;
25757},{"./util/merge":228}],218:[function(require,module,exports){
25758"use strict";
25759
25760Object.defineProperty(exports, "__esModule", {
25761 value: true
25762});
25763exports.default = rtrim;
25764
25765var _assertString = _interopRequireDefault(require("./util/assertString"));
25766
25767function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25768
25769function rtrim(str, chars) {
25770 (0, _assertString.default)(str);
25771 var pattern = chars ? new RegExp("[".concat(chars, "]")) : /\s/;
25772 var idx = str.length - 1;
25773
25774 for (; idx >= 0 && pattern.test(str[idx]); idx--) {
25775 ;
25776 }
25777
25778 return idx < str.length ? str.substr(0, idx + 1) : str;
25779}
25780
25781module.exports = exports.default;
25782module.exports.default = exports.default;
25783},{"./util/assertString":226}],219:[function(require,module,exports){
25784"use strict";
25785
25786Object.defineProperty(exports, "__esModule", {
25787 value: true
25788});
25789exports.default = stripLow;
25790
25791var _assertString = _interopRequireDefault(require("./util/assertString"));
25792
25793var _blacklist = _interopRequireDefault(require("./blacklist"));
25794
25795function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25796
25797function stripLow(str, keep_new_lines) {
25798 (0, _assertString.default)(str);
25799 var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F';
25800 return (0, _blacklist.default)(str, chars);
25801}
25802
25803module.exports = exports.default;
25804module.exports.default = exports.default;
25805},{"./blacklist":155,"./util/assertString":226}],220:[function(require,module,exports){
25806"use strict";
25807
25808Object.defineProperty(exports, "__esModule", {
25809 value: true
25810});
25811exports.default = toBoolean;
25812
25813var _assertString = _interopRequireDefault(require("./util/assertString"));
25814
25815function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25816
25817function toBoolean(str, strict) {
25818 (0, _assertString.default)(str);
25819
25820 if (strict) {
25821 return str === '1' || str === 'true';
25822 }
25823
25824 return str !== '0' && str !== 'false' && str !== '';
25825}
25826
25827module.exports = exports.default;
25828module.exports.default = exports.default;
25829},{"./util/assertString":226}],221:[function(require,module,exports){
25830"use strict";
25831
25832Object.defineProperty(exports, "__esModule", {
25833 value: true
25834});
25835exports.default = toDate;
25836
25837var _assertString = _interopRequireDefault(require("./util/assertString"));
25838
25839function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25840
25841function toDate(date) {
25842 (0, _assertString.default)(date);
25843 date = Date.parse(date);
25844 return !isNaN(date) ? new Date(date) : null;
25845}
25846
25847module.exports = exports.default;
25848module.exports.default = exports.default;
25849},{"./util/assertString":226}],222:[function(require,module,exports){
25850"use strict";
25851
25852Object.defineProperty(exports, "__esModule", {
25853 value: true
25854});
25855exports.default = toFloat;
25856
25857var _assertString = _interopRequireDefault(require("./util/assertString"));
25858
25859function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25860
25861function toFloat(str) {
25862 (0, _assertString.default)(str);
25863 return parseFloat(str);
25864}
25865
25866module.exports = exports.default;
25867module.exports.default = exports.default;
25868},{"./util/assertString":226}],223:[function(require,module,exports){
25869"use strict";
25870
25871Object.defineProperty(exports, "__esModule", {
25872 value: true
25873});
25874exports.default = toInt;
25875
25876var _assertString = _interopRequireDefault(require("./util/assertString"));
25877
25878function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25879
25880function toInt(str, radix) {
25881 (0, _assertString.default)(str);
25882 return parseInt(str, radix || 10);
25883}
25884
25885module.exports = exports.default;
25886module.exports.default = exports.default;
25887},{"./util/assertString":226}],224:[function(require,module,exports){
25888"use strict";
25889
25890Object.defineProperty(exports, "__esModule", {
25891 value: true
25892});
25893exports.default = trim;
25894
25895var _rtrim = _interopRequireDefault(require("./rtrim"));
25896
25897var _ltrim = _interopRequireDefault(require("./ltrim"));
25898
25899function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25900
25901function trim(str, chars) {
25902 return (0, _rtrim.default)((0, _ltrim.default)(str, chars), chars);
25903}
25904
25905module.exports = exports.default;
25906module.exports.default = exports.default;
25907},{"./ltrim":215,"./rtrim":218}],225:[function(require,module,exports){
25908"use strict";
25909
25910Object.defineProperty(exports, "__esModule", {
25911 value: true
25912});
25913exports.default = unescape;
25914
25915var _assertString = _interopRequireDefault(require("./util/assertString"));
25916
25917function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25918
25919function unescape(str) {
25920 (0, _assertString.default)(str);
25921 return str.replace(/&amp;/g, '&').replace(/&quot;/g, '"').replace(/&#x27;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&#x2F;/g, '/').replace(/&#x5C;/g, '\\').replace(/&#96;/g, '`');
25922}
25923
25924module.exports = exports.default;
25925module.exports.default = exports.default;
25926},{"./util/assertString":226}],226:[function(require,module,exports){
25927"use strict";
25928
25929Object.defineProperty(exports, "__esModule", {
25930 value: true
25931});
25932exports.default = assertString;
25933
25934function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
25935
25936function assertString(input) {
25937 var isString = typeof input === 'string' || input instanceof String;
25938
25939 if (!isString) {
25940 var invalidType;
25941
25942 if (input === null) {
25943 invalidType = 'null';
25944 } else {
25945 invalidType = _typeof(input);
25946
25947 if (invalidType === 'object' && input.constructor && input.constructor.hasOwnProperty('name')) {
25948 invalidType = input.constructor.name;
25949 } else {
25950 invalidType = "a ".concat(invalidType);
25951 }
25952 }
25953
25954 throw new TypeError("Expected string but received ".concat(invalidType, "."));
25955 }
25956}
25957
25958module.exports = exports.default;
25959module.exports.default = exports.default;
25960},{}],227:[function(require,module,exports){
25961"use strict";
25962
25963Object.defineProperty(exports, "__esModule", {
25964 value: true
25965});
25966exports.default = void 0;
25967
25968var includes = function includes(arr, val) {
25969 return arr.some(function (arrVal) {
25970 return val === arrVal;
25971 });
25972};
25973
25974var _default = includes;
25975exports.default = _default;
25976module.exports = exports.default;
25977module.exports.default = exports.default;
25978},{}],228:[function(require,module,exports){
25979"use strict";
25980
25981Object.defineProperty(exports, "__esModule", {
25982 value: true
25983});
25984exports.default = merge;
25985
25986function merge() {
25987 var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25988 var defaults = arguments.length > 1 ? arguments[1] : undefined;
25989
25990 for (var key in defaults) {
25991 if (typeof obj[key] === 'undefined') {
25992 obj[key] = defaults[key];
25993 }
25994 }
25995
25996 return obj;
25997}
25998
25999module.exports = exports.default;
26000module.exports.default = exports.default;
26001},{}],229:[function(require,module,exports){
26002"use strict";
26003
26004Object.defineProperty(exports, "__esModule", {
26005 value: true
26006});
26007exports.default = toString;
26008
26009function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
26010
26011function toString(input) {
26012 if (_typeof(input) === 'object' && input !== null) {
26013 if (typeof input.toString === 'function') {
26014 input = input.toString();
26015 } else {
26016 input = '[object Object]';
26017 }
26018 } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
26019 input = '';
26020 }
26021
26022 return String(input);
26023}
26024
26025module.exports = exports.default;
26026module.exports.default = exports.default;
26027},{}],230:[function(require,module,exports){
26028"use strict";
26029
26030Object.defineProperty(exports, "__esModule", {
26031 value: true
26032});
26033exports.default = whitelist;
26034
26035var _assertString = _interopRequireDefault(require("./util/assertString"));
26036
26037function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26038
26039function whitelist(str, chars) {
26040 (0, _assertString.default)(str);
26041 return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), '');
26042}
26043
26044module.exports = exports.default;
26045module.exports.default = exports.default;
26046},{"./util/assertString":226}],231:[function(require,module,exports){
26047module.exports = extend
26048
26049var hasOwnProperty = Object.prototype.hasOwnProperty;
26050
26051function extend() {
26052 var target = {}
26053
26054 for (var i = 0; i < arguments.length; i++) {
26055 var source = arguments[i]
26056
26057 for (var key in source) {
26058 if (hasOwnProperty.call(source, key)) {
26059 target[key] = source[key]
26060 }
26061 }
26062 }
26063
26064 return target
26065}
26066
26067},{}],232:[function(require,module,exports){
26068"use strict";
26069
26070module.exports = {
26071
26072 INVALID_TYPE: "Expected type {0} but found type {1}",
26073 INVALID_FORMAT: "Object didn't pass validation for format {0}: {1}",
26074 ENUM_MISMATCH: "No enum match for: {0}",
26075 ENUM_CASE_MISMATCH: "Enum does not match case for: {0}",
26076 ANY_OF_MISSING: "Data does not match any schemas from 'anyOf'",
26077 ONE_OF_MISSING: "Data does not match any schemas from 'oneOf'",
26078 ONE_OF_MULTIPLE: "Data is valid against more than one schema from 'oneOf'",
26079 NOT_PASSED: "Data matches schema from 'not'",
26080
26081 // Array errors
26082 ARRAY_LENGTH_SHORT: "Array is too short ({0}), minimum {1}",
26083 ARRAY_LENGTH_LONG: "Array is too long ({0}), maximum {1}",
26084 ARRAY_UNIQUE: "Array items are not unique (indexes {0} and {1})",
26085 ARRAY_ADDITIONAL_ITEMS: "Additional items not allowed",
26086
26087 // Numeric errors
26088 MULTIPLE_OF: "Value {0} is not a multiple of {1}",
26089 MINIMUM: "Value {0} is less than minimum {1}",
26090 MINIMUM_EXCLUSIVE: "Value {0} is equal or less than exclusive minimum {1}",
26091 MAXIMUM: "Value {0} is greater than maximum {1}",
26092 MAXIMUM_EXCLUSIVE: "Value {0} is equal or greater than exclusive maximum {1}",
26093
26094 // Object errors
26095 OBJECT_PROPERTIES_MINIMUM: "Too few properties defined ({0}), minimum {1}",
26096 OBJECT_PROPERTIES_MAXIMUM: "Too many properties defined ({0}), maximum {1}",
26097 OBJECT_MISSING_REQUIRED_PROPERTY: "Missing required property: {0}",
26098 OBJECT_ADDITIONAL_PROPERTIES: "Additional properties not allowed: {0}",
26099 OBJECT_DEPENDENCY_KEY: "Dependency failed - key must exist: {0} (due to key: {1})",
26100
26101 // String errors
26102 MIN_LENGTH: "String is too short ({0} chars), minimum {1}",
26103 MAX_LENGTH: "String is too long ({0} chars), maximum {1}",
26104 PATTERN: "String does not match pattern {0}: {1}",
26105
26106 // Schema validation errors
26107 KEYWORD_TYPE_EXPECTED: "Keyword '{0}' is expected to be of type '{1}'",
26108 KEYWORD_UNDEFINED_STRICT: "Keyword '{0}' must be defined in strict mode",
26109 KEYWORD_UNEXPECTED: "Keyword '{0}' is not expected to appear in the schema",
26110 KEYWORD_MUST_BE: "Keyword '{0}' must be {1}",
26111 KEYWORD_DEPENDENCY: "Keyword '{0}' requires keyword '{1}'",
26112 KEYWORD_PATTERN: "Keyword '{0}' is not a valid RegExp pattern: {1}",
26113 KEYWORD_VALUE_TYPE: "Each element of keyword '{0}' array must be a '{1}'",
26114 UNKNOWN_FORMAT: "There is no validation function for format '{0}'",
26115 CUSTOM_MODE_FORCE_PROPERTIES: "{0} must define at least one property if present",
26116
26117 // Remote errors
26118 REF_UNRESOLVED: "Reference has not been resolved during compilation: {0}",
26119 UNRESOLVABLE_REFERENCE: "Reference could not be resolved: {0}",
26120 SCHEMA_NOT_REACHABLE: "Validator was not able to read schema with uri: {0}",
26121 SCHEMA_TYPE_EXPECTED: "Schema is expected to be of type 'object'",
26122 SCHEMA_NOT_AN_OBJECT: "Schema is not an object: {0}",
26123 ASYNC_TIMEOUT: "{0} asynchronous task(s) have timed out after {1} ms",
26124 PARENT_SCHEMA_VALIDATION_FAILED: "Schema failed to validate against its parent schema, see inner errors for details.",
26125 REMOTE_NOT_VALID: "Remote reference didn't compile successfully: {0}"
26126
26127};
26128
26129},{}],233:[function(require,module,exports){
26130/*jshint maxlen: false*/
26131
26132var validator = require("validator");
26133
26134var FormatValidators = {
26135 "date": function (date) {
26136 if (typeof date !== "string") {
26137 return true;
26138 }
26139 // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
26140 var matches = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(date);
26141 if (matches === null) {
26142 return false;
26143 }
26144 // var year = matches[1];
26145 // var month = matches[2];
26146 // var day = matches[3];
26147 if (matches[2] < "01" || matches[2] > "12" || matches[3] < "01" || matches[3] > "31") {
26148 return false;
26149 }
26150 return true;
26151 },
26152 "date-time": function (dateTime) {
26153 if (typeof dateTime !== "string") {
26154 return true;
26155 }
26156 // date-time from http://tools.ietf.org/html/rfc3339#section-5.6
26157 var s = dateTime.toLowerCase().split("t");
26158 if (!FormatValidators.date(s[0])) {
26159 return false;
26160 }
26161 var matches = /^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$/.exec(s[1]);
26162 if (matches === null) {
26163 return false;
26164 }
26165 // var hour = matches[1];
26166 // var minute = matches[2];
26167 // var second = matches[3];
26168 // var fraction = matches[4];
26169 // var timezone = matches[5];
26170 if (matches[1] > "23" || matches[2] > "59" || matches[3] > "59") {
26171 return false;
26172 }
26173 return true;
26174 },
26175 "email": function (email) {
26176 if (typeof email !== "string") {
26177 return true;
26178 }
26179 return validator.isEmail(email, { "require_tld": true });
26180 },
26181 "hostname": function (hostname) {
26182 if (typeof hostname !== "string") {
26183 return true;
26184 }
26185 /*
26186 http://json-schema.org/latest/json-schema-validation.html#anchor114
26187 A string instance is valid against this attribute if it is a valid
26188 representation for an Internet host name, as defined by RFC 1034, section 3.1 [RFC1034].
26189
26190 http://tools.ietf.org/html/rfc1034#section-3.5
26191
26192 <digit> ::= any one of the ten digits 0 through 9
26193 var digit = /[0-9]/;
26194
26195 <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
26196 var letter = /[a-zA-Z]/;
26197
26198 <let-dig> ::= <letter> | <digit>
26199 var letDig = /[0-9a-zA-Z]/;
26200
26201 <let-dig-hyp> ::= <let-dig> | "-"
26202 var letDigHyp = /[-0-9a-zA-Z]/;
26203
26204 <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
26205 var ldhStr = /[-0-9a-zA-Z]+/;
26206
26207 <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
26208 var label = /[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?/;
26209
26210 <subdomain> ::= <label> | <subdomain> "." <label>
26211 var subdomain = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/;
26212
26213 <domain> ::= <subdomain> | " "
26214 var domain = null;
26215 */
26216 var valid = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/.test(hostname);
26217 if (valid) {
26218 // the sum of all label octets and label lengths is limited to 255.
26219 if (hostname.length > 255) { return false; }
26220 // Each node has a label, which is zero to 63 octets in length
26221 var labels = hostname.split(".");
26222 for (var i = 0; i < labels.length; i++) { if (labels[i].length > 63) { return false; } }
26223 }
26224 return valid;
26225 },
26226 "host-name": function (hostname) {
26227 return FormatValidators.hostname.call(this, hostname);
26228 },
26229 "ipv4": function (ipv4) {
26230 if (typeof ipv4 !== "string") { return true; }
26231 return validator.isIP(ipv4, 4);
26232 },
26233 "ipv6": function (ipv6) {
26234 if (typeof ipv6 !== "string") { return true; }
26235 return validator.isIP(ipv6, 6);
26236 },
26237 "regex": function (str) {
26238 try {
26239 RegExp(str);
26240 return true;
26241 } catch (e) {
26242 return false;
26243 }
26244 },
26245 "uri": function (uri) {
26246 if (this.options.strictUris) {
26247 return FormatValidators["strict-uri"].apply(this, arguments);
26248 }
26249 // https://github.com/zaggino/z-schema/issues/18
26250 // RegExp from http://tools.ietf.org/html/rfc3986#appendix-B
26251 return typeof uri !== "string" || RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?").test(uri);
26252 },
26253 "strict-uri": function (uri) {
26254 return typeof uri !== "string" || validator.isURL(uri);
26255 }
26256};
26257
26258module.exports = FormatValidators;
26259
26260},{"validator":153}],234:[function(require,module,exports){
26261"use strict";
26262
26263var FormatValidators = require("./FormatValidators"),
26264 Report = require("./Report"),
26265 Utils = require("./Utils");
26266
26267var JsonValidators = {
26268 multipleOf: function (report, schema, json) {
26269 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.1.2
26270 if (typeof json !== "number") {
26271 return;
26272 }
26273 if (Utils.whatIs(json / schema.multipleOf) !== "integer") {
26274 report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema);
26275 }
26276 },
26277 maximum: function (report, schema, json) {
26278 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.2.2
26279 if (typeof json !== "number") {
26280 return;
26281 }
26282 if (schema.exclusiveMaximum !== true) {
26283 if (json > schema.maximum) {
26284 report.addError("MAXIMUM", [json, schema.maximum], null, schema);
26285 }
26286 } else {
26287 if (json >= schema.maximum) {
26288 report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], null, schema);
26289 }
26290 }
26291 },
26292 exclusiveMaximum: function () {
26293 // covered in maximum
26294 },
26295 minimum: function (report, schema, json) {
26296 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.3.2
26297 if (typeof json !== "number") {
26298 return;
26299 }
26300 if (schema.exclusiveMinimum !== true) {
26301 if (json < schema.minimum) {
26302 report.addError("MINIMUM", [json, schema.minimum], null, schema);
26303 }
26304 } else {
26305 if (json <= schema.minimum) {
26306 report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], null, schema);
26307 }
26308 }
26309 },
26310 exclusiveMinimum: function () {
26311 // covered in minimum
26312 },
26313 maxLength: function (report, schema, json) {
26314 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1.2
26315 if (typeof json !== "string") {
26316 return;
26317 }
26318 if (Utils.ucs2decode(json).length > schema.maxLength) {
26319 report.addError("MAX_LENGTH", [json.length, schema.maxLength], null, schema);
26320 }
26321 },
26322 minLength: function (report, schema, json) {
26323 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.2.2
26324 if (typeof json !== "string") {
26325 return;
26326 }
26327 if (Utils.ucs2decode(json).length < schema.minLength) {
26328 report.addError("MIN_LENGTH", [json.length, schema.minLength], null, schema);
26329 }
26330 },
26331 pattern: function (report, schema, json) {
26332 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.3.2
26333 if (typeof json !== "string") {
26334 return;
26335 }
26336 if (RegExp(schema.pattern).test(json) === false) {
26337 report.addError("PATTERN", [schema.pattern, json], null, schema);
26338 }
26339 },
26340 additionalItems: function (report, schema, json) {
26341 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.1.2
26342 if (!Array.isArray(json)) {
26343 return;
26344 }
26345 // if the value of "additionalItems" is boolean value false and the value of "items" is an array,
26346 // the json is valid if its size is less than, or equal to, the size of "items".
26347 if (schema.additionalItems === false && Array.isArray(schema.items)) {
26348 if (json.length > schema.items.length) {
26349 report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema);
26350 }
26351 }
26352 },
26353 items: function () { /*report, schema, json*/
26354 // covered in additionalItems
26355 },
26356 maxItems: function (report, schema, json) {
26357 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.2.2
26358 if (!Array.isArray(json)) {
26359 return;
26360 }
26361 if (json.length > schema.maxItems) {
26362 report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], null, schema);
26363 }
26364 },
26365 minItems: function (report, schema, json) {
26366 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.3.2
26367 if (!Array.isArray(json)) {
26368 return;
26369 }
26370 if (json.length < schema.minItems) {
26371 report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], null, schema);
26372 }
26373 },
26374 uniqueItems: function (report, schema, json) {
26375 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.4.2
26376 if (!Array.isArray(json)) {
26377 return;
26378 }
26379 if (schema.uniqueItems === true) {
26380 var matches = [];
26381 if (Utils.isUniqueArray(json, matches) === false) {
26382 report.addError("ARRAY_UNIQUE", matches, null, schema);
26383 }
26384 }
26385 },
26386 maxProperties: function (report, schema, json) {
26387 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.1.2
26388 if (Utils.whatIs(json) !== "object") {
26389 return;
26390 }
26391 var keysCount = Object.keys(json).length;
26392 if (keysCount > schema.maxProperties) {
26393 report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], null, schema);
26394 }
26395 },
26396 minProperties: function (report, schema, json) {
26397 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.2.2
26398 if (Utils.whatIs(json) !== "object") {
26399 return;
26400 }
26401 var keysCount = Object.keys(json).length;
26402 if (keysCount < schema.minProperties) {
26403 report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], null, schema);
26404 }
26405 },
26406 required: function (report, schema, json) {
26407 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.3.2
26408 if (Utils.whatIs(json) !== "object") {
26409 return;
26410 }
26411 var idx = schema.required.length;
26412 while (idx--) {
26413 var requiredPropertyName = schema.required[idx];
26414 if (json[requiredPropertyName] === undefined) {
26415 report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], null, schema);
26416 }
26417 }
26418 },
26419 additionalProperties: function (report, schema, json) {
26420 // covered in properties and patternProperties
26421 if (schema.properties === undefined && schema.patternProperties === undefined) {
26422 return JsonValidators.properties.call(this, report, schema, json);
26423 }
26424 },
26425 patternProperties: function (report, schema, json) {
26426 // covered in properties
26427 if (schema.properties === undefined) {
26428 return JsonValidators.properties.call(this, report, schema, json);
26429 }
26430 },
26431 properties: function (report, schema, json) {
26432 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.2
26433 if (Utils.whatIs(json) !== "object") {
26434 return;
26435 }
26436 var properties = schema.properties !== undefined ? schema.properties : {};
26437 var patternProperties = schema.patternProperties !== undefined ? schema.patternProperties : {};
26438 if (schema.additionalProperties === false) {
26439 // The property set of the json to validate.
26440 var s = Object.keys(json);
26441 // The property set from "properties".
26442 var p = Object.keys(properties);
26443 // The property set from "patternProperties".
26444 var pp = Object.keys(patternProperties);
26445 // remove from "s" all elements of "p", if any;
26446 s = Utils.difference(s, p);
26447 // for each regex in "pp", remove all elements of "s" which this regex matches.
26448 var idx = pp.length;
26449 while (idx--) {
26450 var regExp = RegExp(pp[idx]),
26451 idx2 = s.length;
26452 while (idx2--) {
26453 if (regExp.test(s[idx2]) === true) {
26454 s.splice(idx2, 1);
26455 }
26456 }
26457 }
26458 // Validation of the json succeeds if, after these two steps, set "s" is empty.
26459 if (s.length > 0) {
26460 // assumeAdditional can be an array of allowed properties
26461 var idx3 = this.options.assumeAdditional.length;
26462 if (idx3) {
26463 while (idx3--) {
26464 var io = s.indexOf(this.options.assumeAdditional[idx3]);
26465 if (io !== -1) {
26466 s.splice(io, 1);
26467 }
26468 }
26469 }
26470 var idx4 = s.length;
26471 if (idx4) {
26472 while (idx4--) {
26473 report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s[idx4]], null, schema);
26474 }
26475 }
26476 }
26477 }
26478 },
26479 dependencies: function (report, schema, json) {
26480 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.5.2
26481 if (Utils.whatIs(json) !== "object") {
26482 return;
26483 }
26484
26485 var keys = Object.keys(schema.dependencies),
26486 idx = keys.length;
26487
26488 while (idx--) {
26489 // iterate all dependencies
26490 var dependencyName = keys[idx];
26491 if (json[dependencyName]) {
26492 var dependencyDefinition = schema.dependencies[dependencyName];
26493 if (Utils.whatIs(dependencyDefinition) === "object") {
26494 // if dependency is a schema, validate against this schema
26495 exports.validate.call(this, report, dependencyDefinition, json);
26496 } else { // Array
26497 // if dependency is an array, object needs to have all properties in this array
26498 var idx2 = dependencyDefinition.length;
26499 while (idx2--) {
26500 var requiredPropertyName = dependencyDefinition[idx2];
26501 if (json[requiredPropertyName] === undefined) {
26502 report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], null, schema);
26503 }
26504 }
26505 }
26506 }
26507 }
26508 },
26509 enum: function (report, schema, json) {
26510 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.1.2
26511 var match = false,
26512 caseInsensitiveMatch = false,
26513 idx = schema.enum.length;
26514 while (idx--) {
26515 if (Utils.areEqual(json, schema.enum[idx])) {
26516 match = true;
26517 break;
26518 } else if (Utils.areEqual(json, schema.enum[idx]), { caseInsensitiveComparison: true }) {
26519 caseInsensitiveMatch = true;
26520 }
26521 }
26522
26523 if (match === false) {
26524 var error = caseInsensitiveMatch && this.options.enumCaseInsensitiveComparison ? "ENUM_CASE_MISMATCH" : "ENUM_MISMATCH";
26525 report.addError(error, [json], null, schema);
26526 }
26527 },
26528 type: function (report, schema, json) {
26529 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.2
26530 var jsonType = Utils.whatIs(json);
26531 if (typeof schema.type === "string") {
26532 if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
26533 report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
26534 }
26535 } else {
26536 if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
26537 report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema);
26538 }
26539 }
26540 },
26541 allOf: function (report, schema, json) {
26542 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.3.2
26543 var idx = schema.allOf.length;
26544 while (idx--) {
26545 var validateResult = exports.validate.call(this, report, schema.allOf[idx], json);
26546 if (this.options.breakOnFirstError && validateResult === false) {
26547 break;
26548 }
26549 }
26550 },
26551 anyOf: function (report, schema, json) {
26552 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.4.2
26553 var subReports = [],
26554 passed = false,
26555 idx = schema.anyOf.length;
26556
26557 while (idx-- && passed === false) {
26558 var subReport = new Report(report);
26559 subReports.push(subReport);
26560 passed = exports.validate.call(this, subReport, schema.anyOf[idx], json);
26561 }
26562
26563 if (passed === false) {
26564 report.addError("ANY_OF_MISSING", undefined, subReports, schema);
26565 }
26566 },
26567 oneOf: function (report, schema, json) {
26568 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.5.2
26569 var passes = 0,
26570 subReports = [],
26571 idx = schema.oneOf.length;
26572
26573 while (idx--) {
26574 var subReport = new Report(report, { maxErrors: 1 });
26575 subReports.push(subReport);
26576 if (exports.validate.call(this, subReport, schema.oneOf[idx], json) === true) {
26577 passes++;
26578 }
26579 }
26580
26581 if (passes === 0) {
26582 report.addError("ONE_OF_MISSING", undefined, subReports, schema);
26583 } else if (passes > 1) {
26584 report.addError("ONE_OF_MULTIPLE", null, null, schema);
26585 }
26586 },
26587 not: function (report, schema, json) {
26588 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.6.2
26589 var subReport = new Report(report);
26590 if (exports.validate.call(this, subReport, schema.not, json) === true) {
26591 report.addError("NOT_PASSED", null, null, schema);
26592 }
26593 },
26594 definitions: function () { /*report, schema, json*/
26595 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.7.2
26596 // nothing to do here
26597 },
26598 format: function (report, schema, json) {
26599 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.7.2
26600 var formatValidatorFn = FormatValidators[schema.format];
26601 if (typeof formatValidatorFn === "function") {
26602 if (formatValidatorFn.length === 2) {
26603 // async
26604 report.addAsyncTask(formatValidatorFn, [json], function (result) {
26605 if (result !== true) {
26606 report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
26607 }
26608 });
26609 } else {
26610 // sync
26611 if (formatValidatorFn.call(this, json) !== true) {
26612 report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
26613 }
26614 }
26615 } else if (this.options.ignoreUnknownFormats !== true) {
26616 report.addError("UNKNOWN_FORMAT", [schema.format], null, schema);
26617 }
26618 }
26619};
26620
26621var recurseArray = function (report, schema, json) {
26622 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.8.2
26623
26624 var idx = json.length;
26625
26626 // If "items" is an array, this situation, the schema depends on the index:
26627 // if the index is less than, or equal to, the size of "items",
26628 // the child instance must be valid against the corresponding schema in the "items" array;
26629 // otherwise, it must be valid against the schema defined by "additionalItems".
26630 if (Array.isArray(schema.items)) {
26631
26632 while (idx--) {
26633 // equal to doesn't make sense here
26634 if (idx < schema.items.length) {
26635 report.path.push(idx.toString());
26636 exports.validate.call(this, report, schema.items[idx], json[idx]);
26637 report.path.pop();
26638 } else {
26639 // might be boolean, so check that it's an object
26640 if (typeof schema.additionalItems === "object") {
26641 report.path.push(idx.toString());
26642 exports.validate.call(this, report, schema.additionalItems, json[idx]);
26643 report.path.pop();
26644 }
26645 }
26646 }
26647
26648 } else if (typeof schema.items === "object") {
26649
26650 // If items is a schema, then the child instance must be valid against this schema,
26651 // regardless of its index, and regardless of the value of "additionalItems".
26652 while (idx--) {
26653 report.path.push(idx.toString());
26654 exports.validate.call(this, report, schema.items, json[idx]);
26655 report.path.pop();
26656 }
26657
26658 }
26659};
26660
26661var recurseObject = function (report, schema, json) {
26662 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.8.3
26663
26664 // If "additionalProperties" is absent, it is considered present with an empty schema as a value.
26665 // In addition, boolean value true is considered equivalent to an empty schema.
26666 var additionalProperties = schema.additionalProperties;
26667 if (additionalProperties === true || additionalProperties === undefined) {
26668 additionalProperties = {};
26669 }
26670
26671 // p - The property set from "properties".
26672 var p = schema.properties ? Object.keys(schema.properties) : [];
26673
26674 // pp - The property set from "patternProperties". Elements of this set will be called regexes for convenience.
26675 var pp = schema.patternProperties ? Object.keys(schema.patternProperties) : [];
26676
26677 // m - The property name of the child.
26678 var keys = Object.keys(json),
26679 idx = keys.length;
26680
26681 while (idx--) {
26682 var m = keys[idx],
26683 propertyValue = json[m];
26684
26685 // s - The set of schemas for the child instance.
26686 var s = [];
26687
26688 // 1. If set "p" contains value "m", then the corresponding schema in "properties" is added to "s".
26689 if (p.indexOf(m) !== -1) {
26690 s.push(schema.properties[m]);
26691 }
26692
26693 // 2. For each regex in "pp", if it matches "m" successfully, the corresponding schema in "patternProperties" is added to "s".
26694 var idx2 = pp.length;
26695 while (idx2--) {
26696 var regexString = pp[idx2];
26697 if (RegExp(regexString).test(m) === true) {
26698 s.push(schema.patternProperties[regexString]);
26699 }
26700 }
26701
26702 // 3. The schema defined by "additionalProperties" is added to "s" if and only if, at this stage, "s" is empty.
26703 if (s.length === 0 && additionalProperties !== false) {
26704 s.push(additionalProperties);
26705 }
26706
26707 // we are passing tests even without this assert because this is covered by properties check
26708 // if s is empty in this stage, no additionalProperties are allowed
26709 // report.expect(s.length !== 0, 'E001', m);
26710
26711 // Instance property value must pass all schemas from s
26712 idx2 = s.length;
26713 while (idx2--) {
26714 report.path.push(m);
26715 exports.validate.call(this, report, s[idx2], propertyValue);
26716
26717 // commented out to resolve issue #209 - the path gets popped before async tasks complete
26718 // all the tests run fine without, there seems to be no reason to have this pop here
26719 // report.path.pop();
26720 }
26721 }
26722};
26723
26724exports.JsonValidators = JsonValidators;
26725
26726/**
26727 *
26728 * @param {Report} report
26729 * @param {*} schema
26730 * @param {*} json
26731 */
26732exports.validate = function (report, schema, json) {
26733
26734 report.commonErrorMessage = "JSON_OBJECT_VALIDATION_FAILED";
26735
26736 // check if schema is an object
26737 var to = Utils.whatIs(schema);
26738 if (to !== "object") {
26739 report.addError("SCHEMA_NOT_AN_OBJECT", [to], null, schema);
26740 return false;
26741 }
26742
26743 // check if schema is empty, everything is valid against empty schema
26744 var keys = Object.keys(schema);
26745 if (keys.length === 0) {
26746 return true;
26747 }
26748
26749 // this method can be called recursively, so we need to remember our root
26750 var isRoot = false;
26751 if (!report.rootSchema) {
26752 report.rootSchema = schema;
26753 isRoot = true;
26754 }
26755
26756 // follow schema.$ref keys
26757 if (schema.$ref !== undefined) {
26758 // avoid infinite loop with maxRefs
26759 var maxRefs = 99;
26760 while (schema.$ref && maxRefs > 0) {
26761 if (!schema.__$refResolved) {
26762 report.addError("REF_UNRESOLVED", [schema.$ref], null, schema);
26763 break;
26764 } else if (schema.__$refResolved === schema) {
26765 break;
26766 } else {
26767 schema = schema.__$refResolved;
26768 keys = Object.keys(schema);
26769 }
26770 maxRefs--;
26771 }
26772 if (maxRefs === 0) {
26773 throw new Error("Circular dependency by $ref references!");
26774 }
26775 }
26776
26777 // type checking first
26778 var jsonType = Utils.whatIs(json);
26779 if (schema.type) {
26780 keys.splice(keys.indexOf("type"), 1);
26781 JsonValidators.type.call(this, report, schema, json);
26782 if (report.errors.length && this.options.breakOnFirstError) {
26783 return false;
26784 }
26785 }
26786
26787 // now iterate all the keys in schema and execute validation methods
26788 var idx = keys.length;
26789 while (idx--) {
26790 if (JsonValidators[keys[idx]]) {
26791 JsonValidators[keys[idx]].call(this, report, schema, json);
26792 if (report.errors.length && this.options.breakOnFirstError) { break; }
26793 }
26794 }
26795
26796 if (report.errors.length === 0 || this.options.breakOnFirstError === false) {
26797 if (jsonType === "array") {
26798 recurseArray.call(this, report, schema, json);
26799 } else if (jsonType === "object") {
26800 recurseObject.call(this, report, schema, json);
26801 }
26802 }
26803
26804 if (typeof this.options.customValidator === "function") {
26805 this.options.customValidator(report, schema, json);
26806 }
26807
26808 // we don't need the root pointer anymore
26809 if (isRoot) {
26810 report.rootSchema = undefined;
26811 }
26812
26813 // return valid just to be able to break at some code points
26814 return report.errors.length === 0;
26815
26816};
26817
26818},{"./FormatValidators":233,"./Report":236,"./Utils":240}],235:[function(require,module,exports){
26819// Number.isFinite polyfill
26820// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite
26821if (typeof Number.isFinite !== "function") {
26822 Number.isFinite = function isFinite(value) {
26823 // 1. If Type(number) is not Number, return false.
26824 if (typeof value !== "number") {
26825 return false;
26826 }
26827 // 2. If number is NaN, +∞, or −∞, return false.
26828 if (value !== value || value === Infinity || value === -Infinity) {
26829 return false;
26830 }
26831 // 3. Otherwise, return true.
26832 return true;
26833 };
26834}
26835
26836},{}],236:[function(require,module,exports){
26837(function (process){
26838"use strict";
26839
26840var get = require("lodash.get");
26841var Errors = require("./Errors");
26842var Utils = require("./Utils");
26843
26844/**
26845 * @class
26846 *
26847 * @param {Report|object} parentOrOptions
26848 * @param {object} [reportOptions]
26849 */
26850function Report(parentOrOptions, reportOptions) {
26851 this.parentReport = parentOrOptions instanceof Report ?
26852 parentOrOptions :
26853 undefined;
26854
26855 this.options = parentOrOptions instanceof Report ?
26856 parentOrOptions.options :
26857 parentOrOptions || {};
26858
26859 this.reportOptions = reportOptions || {};
26860
26861 this.errors = [];
26862 /**
26863 * @type {string[]}
26864 */
26865 this.path = [];
26866 this.asyncTasks = [];
26867
26868 this.rootSchema = undefined;
26869 this.commonErrorMessage = undefined;
26870 this.json = undefined;
26871}
26872
26873/**
26874 * @returns {boolean}
26875 */
26876Report.prototype.isValid = function () {
26877 if (this.asyncTasks.length > 0) {
26878 throw new Error("Async tasks pending, can't answer isValid");
26879 }
26880 return this.errors.length === 0;
26881};
26882
26883/**
26884 *
26885 * @param {*} fn
26886 * @param {*} args
26887 * @param {*} asyncTaskResultProcessFn
26888 */
26889Report.prototype.addAsyncTask = function (fn, args, asyncTaskResultProcessFn) {
26890 this.asyncTasks.push([fn, args, asyncTaskResultProcessFn]);
26891};
26892
26893/**
26894 *
26895 * @param {*} timeout
26896 * @param {function(*, *)} callback
26897 *
26898 * @returns {void}
26899 */
26900Report.prototype.processAsyncTasks = function (timeout, callback) {
26901
26902 var validationTimeout = timeout || 2000,
26903 tasksCount = this.asyncTasks.length,
26904 idx = tasksCount,
26905 timedOut = false,
26906 self = this;
26907
26908 function finish() {
26909 process.nextTick(function () {
26910 var valid = self.errors.length === 0,
26911 err = valid ? undefined : self.errors;
26912 callback(err, valid);
26913 });
26914 }
26915
26916 function respond(asyncTaskResultProcessFn) {
26917 return function (asyncTaskResult) {
26918 if (timedOut) { return; }
26919 asyncTaskResultProcessFn(asyncTaskResult);
26920 if (--tasksCount === 0) {
26921 finish();
26922 }
26923 };
26924 }
26925
26926 // finish if tasks are completed or there are any errors and breaking on first error was requested
26927 if (tasksCount === 0 || (this.errors.length > 0 && this.options.breakOnFirstError)) {
26928 finish();
26929 return;
26930 }
26931
26932 while (idx--) {
26933 var task = this.asyncTasks[idx];
26934 task[0].apply(null, task[1].concat(respond(task[2])));
26935 }
26936
26937 setTimeout(function () {
26938 if (tasksCount > 0) {
26939 timedOut = true;
26940 self.addError("ASYNC_TIMEOUT", [tasksCount, validationTimeout]);
26941 callback(self.errors, false);
26942 }
26943 }, validationTimeout);
26944
26945};
26946
26947/**
26948 *
26949 * @param {*} returnPathAsString
26950 *
26951 * @return {string[]|string}
26952 */
26953Report.prototype.getPath = function (returnPathAsString) {
26954 /**
26955 * @type {string[]|string}
26956 */
26957 var path = [];
26958 if (this.parentReport) {
26959 path = path.concat(this.parentReport.path);
26960 }
26961 path = path.concat(this.path);
26962
26963 if (returnPathAsString !== true) {
26964 // Sanitize the path segments (http://tools.ietf.org/html/rfc6901#section-4)
26965 path = "#/" + path.map(function (segment) {
26966
26967 if (Utils.isAbsoluteUri(segment)) {
26968 return "uri(" + segment + ")";
26969 }
26970
26971 return segment.replace(/\~/g, "~0").replace(/\//g, "~1");
26972 }).join("/");
26973 }
26974 return path;
26975};
26976
26977Report.prototype.getSchemaId = function () {
26978
26979 if (!this.rootSchema) {
26980 return null;
26981 }
26982
26983 // get the error path as an array
26984 var path = [];
26985 if (this.parentReport) {
26986 path = path.concat(this.parentReport.path);
26987 }
26988 path = path.concat(this.path);
26989
26990 // try to find id in the error path
26991 while (path.length > 0) {
26992 var obj = get(this.rootSchema, path);
26993 if (obj && obj.id) { return obj.id; }
26994 path.pop();
26995 }
26996
26997 // return id of the root
26998 return this.rootSchema.id;
26999};
27000
27001/**
27002 *
27003 * @param {*} errorCode
27004 * @param {*} params
27005 *
27006 * @return {boolean}
27007 */
27008Report.prototype.hasError = function (errorCode, params) {
27009 var idx = this.errors.length;
27010 while (idx--) {
27011 if (this.errors[idx].code === errorCode) {
27012 // assume match
27013 var match = true;
27014
27015 // check the params too
27016 var idx2 = this.errors[idx].params.length;
27017 while (idx2--) {
27018 if (this.errors[idx].params[idx2] !== params[idx2]) {
27019 match = false;
27020 }
27021 }
27022
27023 // if match, return true
27024 if (match) { return match; }
27025 }
27026 }
27027 return false;
27028};
27029
27030/**
27031 *
27032 * @param {*} errorCode
27033 * @param {*} params
27034 * @param {Report[]|Report} [subReports]
27035 * @param {*} [schema]
27036 *
27037 * @return {void}
27038 */
27039Report.prototype.addError = function (errorCode, params, subReports, schema) {
27040 if (!errorCode) { throw new Error("No errorCode passed into addError()"); }
27041
27042 this.addCustomError(errorCode, Errors[errorCode], params, subReports, schema);
27043};
27044
27045Report.prototype.getJson = function () {
27046 var self = this;
27047 while (self.json === undefined) {
27048 self = self.parentReport;
27049 if (self === undefined) {
27050 return undefined;
27051 }
27052 }
27053 return self.json;
27054};
27055
27056/**
27057 *
27058 * @param {*} errorCode
27059 * @param {*} errorMessage
27060 * @param {*[]} params
27061 * @param {Report[]|Report} subReports
27062 * @param {*} schema
27063 *
27064 * @returns {void}
27065 */
27066Report.prototype.addCustomError = function (errorCode, errorMessage, params, subReports, schema) {
27067 if (this.errors.length >= this.reportOptions.maxErrors) {
27068 return;
27069 }
27070
27071 if (!errorMessage) { throw new Error("No errorMessage known for code " + errorCode); }
27072
27073 params = params || [];
27074
27075 var idx = params.length;
27076 while (idx--) {
27077 var whatIs = Utils.whatIs(params[idx]);
27078 var param = (whatIs === "object" || whatIs === "null") ? JSON.stringify(params[idx]) : params[idx];
27079 errorMessage = errorMessage.replace("{" + idx + "}", param);
27080 }
27081
27082 var err = {
27083 code: errorCode,
27084 params: params,
27085 message: errorMessage,
27086 path: this.getPath(this.options.reportPathAsArray),
27087 schemaId: this.getSchemaId()
27088 };
27089
27090 err[Utils.schemaSymbol] = schema;
27091 err[Utils.jsonSymbol] = this.getJson();
27092
27093 if (schema && typeof schema === "string") {
27094 err.description = schema;
27095 } else if (schema && typeof schema === "object") {
27096 if (schema.title) {
27097 err.title = schema.title;
27098 }
27099 if (schema.description) {
27100 err.description = schema.description;
27101 }
27102 }
27103
27104 if (subReports != null) {
27105 if (!Array.isArray(subReports)) {
27106 subReports = [subReports];
27107 }
27108 err.inner = [];
27109 idx = subReports.length;
27110 while (idx--) {
27111 var subReport = subReports[idx],
27112 idx2 = subReport.errors.length;
27113 while (idx2--) {
27114 err.inner.push(subReport.errors[idx2]);
27115 }
27116 }
27117 if (err.inner.length === 0) {
27118 err.inner = undefined;
27119 }
27120 }
27121
27122 this.errors.push(err);
27123};
27124
27125module.exports = Report;
27126
27127}).call(this,require('_process'))
27128
27129},{"./Errors":232,"./Utils":240,"_process":125,"lodash.get":120}],237:[function(require,module,exports){
27130"use strict";
27131
27132var isequal = require("lodash.isequal");
27133var Report = require("./Report");
27134var SchemaCompilation = require("./SchemaCompilation");
27135var SchemaValidation = require("./SchemaValidation");
27136var Utils = require("./Utils");
27137
27138function decodeJSONPointer(str) {
27139 // http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07#section-3
27140 return decodeURIComponent(str).replace(/~[0-1]/g, function (x) {
27141 return x === "~1" ? "/" : "~";
27142 });
27143}
27144
27145function getRemotePath(uri) {
27146 var io = uri.indexOf("#");
27147 return io === -1 ? uri : uri.slice(0, io);
27148}
27149
27150function getQueryPath(uri) {
27151 var io = uri.indexOf("#");
27152 var res = io === -1 ? undefined : uri.slice(io + 1);
27153 // WARN: do not slice slash, #/ means take root and go down from it
27154 // if (res && res[0] === "/") { res = res.slice(1); }
27155 return res;
27156}
27157
27158function findId(schema, id) {
27159 // process only arrays and objects
27160 if (typeof schema !== "object" || schema === null) {
27161 return;
27162 }
27163
27164 // no id means root so return itself
27165 if (!id) {
27166 return schema;
27167 }
27168
27169 if (schema.id) {
27170 if (schema.id === id || schema.id[0] === "#" && schema.id.substring(1) === id) {
27171 return schema;
27172 }
27173 }
27174
27175 var idx, result;
27176 if (Array.isArray(schema)) {
27177 idx = schema.length;
27178 while (idx--) {
27179 result = findId(schema[idx], id);
27180 if (result) { return result; }
27181 }
27182 } else {
27183 var keys = Object.keys(schema);
27184 idx = keys.length;
27185 while (idx--) {
27186 var k = keys[idx];
27187 if (k.indexOf("__$") === 0) {
27188 continue;
27189 }
27190 result = findId(schema[k], id);
27191 if (result) { return result; }
27192 }
27193 }
27194}
27195
27196/**
27197 *
27198 * @param {*} uri
27199 * @param {*} schema
27200 *
27201 * @returns {void}
27202 */
27203exports.cacheSchemaByUri = function (uri, schema) {
27204 var remotePath = getRemotePath(uri);
27205 if (remotePath) {
27206 this.cache[remotePath] = schema;
27207 }
27208};
27209
27210/**
27211 *
27212 * @param {*} uri
27213 *
27214 * @returns {void}
27215 */
27216exports.removeFromCacheByUri = function (uri) {
27217 var remotePath = getRemotePath(uri);
27218 if (remotePath) {
27219 delete this.cache[remotePath];
27220 }
27221};
27222
27223/**
27224 *
27225 * @param {*} uri
27226 *
27227 * @returns {boolean}
27228 */
27229exports.checkCacheForUri = function (uri) {
27230 var remotePath = getRemotePath(uri);
27231 return remotePath ? this.cache[remotePath] != null : false;
27232};
27233
27234exports.getSchema = function (report, schema) {
27235 if (typeof schema === "object") {
27236 schema = exports.getSchemaByReference.call(this, report, schema);
27237 }
27238 if (typeof schema === "string") {
27239 schema = exports.getSchemaByUri.call(this, report, schema);
27240 }
27241 return schema;
27242};
27243
27244exports.getSchemaByReference = function (report, key) {
27245 var i = this.referenceCache.length;
27246 while (i--) {
27247 if (isequal(this.referenceCache[i][0], key)) {
27248 return this.referenceCache[i][1];
27249 }
27250 }
27251 // not found
27252 var schema = Utils.cloneDeep(key);
27253 this.referenceCache.push([key, schema]);
27254 return schema;
27255};
27256
27257exports.getSchemaByUri = function (report, uri, root) {
27258 var remotePath = getRemotePath(uri),
27259 queryPath = getQueryPath(uri),
27260 result = remotePath ? this.cache[remotePath] : root;
27261
27262 if (result && remotePath) {
27263 // we need to avoid compiling schemas in a recursive loop
27264 var compileRemote = result !== root;
27265 // now we need to compile and validate resolved schema (in case it's not already)
27266 if (compileRemote) {
27267
27268 report.path.push(remotePath);
27269
27270 var remoteReport = new Report(report);
27271 if (SchemaCompilation.compileSchema.call(this, remoteReport, result)) {
27272 var savedOptions = this.options;
27273 try {
27274 // If custom validationOptions were provided to setRemoteReference(),
27275 // use them instead of the default options
27276 this.options = result.__$validationOptions || this.options;
27277 SchemaValidation.validateSchema.call(this, remoteReport, result);
27278 } finally {
27279 this.options = savedOptions;
27280 }
27281 }
27282 var remoteReportIsValid = remoteReport.isValid();
27283 if (!remoteReportIsValid) {
27284 report.addError("REMOTE_NOT_VALID", [uri], remoteReport);
27285 }
27286
27287 report.path.pop();
27288
27289 if (!remoteReportIsValid) {
27290 return undefined;
27291 }
27292 }
27293 }
27294
27295 if (result && queryPath) {
27296 var parts = queryPath.split("/");
27297 for (var idx = 0, lim = parts.length; result && idx < lim; idx++) {
27298 var key = decodeJSONPointer(parts[idx]);
27299 if (idx === 0) { // it's an id
27300 result = findId(result, key);
27301 } else { // it's a path behind id
27302 result = result[key];
27303 }
27304 }
27305 }
27306
27307 return result;
27308};
27309
27310exports.getRemotePath = getRemotePath;
27311
27312},{"./Report":236,"./SchemaCompilation":238,"./SchemaValidation":239,"./Utils":240,"lodash.isequal":121}],238:[function(require,module,exports){
27313"use strict";
27314
27315var Report = require("./Report");
27316var SchemaCache = require("./SchemaCache");
27317var Utils = require("./Utils");
27318
27319function mergeReference(scope, ref) {
27320 if (Utils.isAbsoluteUri(ref)) {
27321 return ref;
27322 }
27323
27324 var joinedScope = scope.join(""),
27325 isScopeAbsolute = Utils.isAbsoluteUri(joinedScope),
27326 isScopeRelative = Utils.isRelativeUri(joinedScope),
27327 isRefRelative = Utils.isRelativeUri(ref),
27328 toRemove;
27329
27330 if (isScopeAbsolute && isRefRelative) {
27331 toRemove = joinedScope.match(/\/[^\/]*$/);
27332 if (toRemove) {
27333 joinedScope = joinedScope.slice(0, toRemove.index + 1);
27334 }
27335 } else if (isScopeRelative && isRefRelative) {
27336 joinedScope = "";
27337 } else {
27338 toRemove = joinedScope.match(/[^#/]+$/);
27339 if (toRemove) {
27340 joinedScope = joinedScope.slice(0, toRemove.index);
27341 }
27342 }
27343
27344 var res = joinedScope + ref;
27345 res = res.replace(/##/, "#");
27346 return res;
27347}
27348
27349function collectReferences(obj, results, scope, path) {
27350 results = results || [];
27351 scope = scope || [];
27352 path = path || [];
27353
27354 if (typeof obj !== "object" || obj === null) {
27355 return results;
27356 }
27357
27358 if (typeof obj.id === "string") {
27359 scope.push(obj.id);
27360 }
27361
27362 if (typeof obj.$ref === "string" && typeof obj.__$refResolved === "undefined") {
27363 results.push({
27364 ref: mergeReference(scope, obj.$ref),
27365 key: "$ref",
27366 obj: obj,
27367 path: path.slice(0)
27368 });
27369 }
27370 if (typeof obj.$schema === "string" && typeof obj.__$schemaResolved === "undefined") {
27371 results.push({
27372 ref: mergeReference(scope, obj.$schema),
27373 key: "$schema",
27374 obj: obj,
27375 path: path.slice(0)
27376 });
27377 }
27378
27379 var idx;
27380 if (Array.isArray(obj)) {
27381 idx = obj.length;
27382 while (idx--) {
27383 path.push(idx.toString());
27384 collectReferences(obj[idx], results, scope, path);
27385 path.pop();
27386 }
27387 } else {
27388 var keys = Object.keys(obj);
27389 idx = keys.length;
27390 while (idx--) {
27391 // do not recurse through resolved references and other z-schema props
27392 if (keys[idx].indexOf("__$") === 0) { continue; }
27393 path.push(keys[idx]);
27394 collectReferences(obj[keys[idx]], results, scope, path);
27395 path.pop();
27396 }
27397 }
27398
27399 if (typeof obj.id === "string") {
27400 scope.pop();
27401 }
27402
27403 return results;
27404}
27405
27406var compileArrayOfSchemasLoop = function (mainReport, arr) {
27407 var idx = arr.length,
27408 compiledCount = 0;
27409
27410 while (idx--) {
27411
27412 // try to compile each schema separately
27413 var report = new Report(mainReport);
27414 var isValid = exports.compileSchema.call(this, report, arr[idx]);
27415 if (isValid) { compiledCount++; }
27416
27417 // copy errors to report
27418 mainReport.errors = mainReport.errors.concat(report.errors);
27419
27420 }
27421
27422 return compiledCount;
27423};
27424
27425function findId(arr, id) {
27426 var idx = arr.length;
27427 while (idx--) {
27428 if (arr[idx].id === id) {
27429 return arr[idx];
27430 }
27431 }
27432 return null;
27433}
27434
27435var compileArrayOfSchemas = function (report, arr) {
27436
27437 var compiled = 0,
27438 lastLoopCompiled;
27439
27440 do {
27441
27442 // remove all UNRESOLVABLE_REFERENCE errors before compiling array again
27443 var idx = report.errors.length;
27444 while (idx--) {
27445 if (report.errors[idx].code === "UNRESOLVABLE_REFERENCE") {
27446 report.errors.splice(idx, 1);
27447 }
27448 }
27449
27450 // remember how many were compiled in the last loop
27451 lastLoopCompiled = compiled;
27452
27453 // count how many are compiled now
27454 compiled = compileArrayOfSchemasLoop.call(this, report, arr);
27455
27456 // fix __$missingReferences if possible
27457 idx = arr.length;
27458 while (idx--) {
27459 var sch = arr[idx];
27460 if (sch.__$missingReferences) {
27461 var idx2 = sch.__$missingReferences.length;
27462 while (idx2--) {
27463 var refObj = sch.__$missingReferences[idx2];
27464 var response = findId(arr, refObj.ref);
27465 if (response) {
27466 // this might create circular references
27467 refObj.obj["__" + refObj.key + "Resolved"] = response;
27468 // it's resolved now so delete it
27469 sch.__$missingReferences.splice(idx2, 1);
27470 }
27471 }
27472 if (sch.__$missingReferences.length === 0) {
27473 delete sch.__$missingReferences;
27474 }
27475 }
27476 }
27477
27478 // keep repeating if not all compiled and at least one more was compiled in the last loop
27479 } while (compiled !== arr.length && compiled !== lastLoopCompiled);
27480
27481 return report.isValid();
27482
27483};
27484
27485exports.compileSchema = function (report, schema) {
27486
27487 report.commonErrorMessage = "SCHEMA_COMPILATION_FAILED";
27488
27489 // if schema is a string, assume it's a uri
27490 if (typeof schema === "string") {
27491 var loadedSchema = SchemaCache.getSchemaByUri.call(this, report, schema);
27492 if (!loadedSchema) {
27493 report.addError("SCHEMA_NOT_REACHABLE", [schema]);
27494 return false;
27495 }
27496 schema = loadedSchema;
27497 }
27498
27499 // if schema is an array, assume it's an array of schemas
27500 if (Array.isArray(schema)) {
27501 return compileArrayOfSchemas.call(this, report, schema);
27502 }
27503
27504 // if we have an id than it should be cached already (if this instance has compiled it)
27505 if (schema.__$compiled && schema.id && SchemaCache.checkCacheForUri.call(this, schema.id) === false) {
27506 schema.__$compiled = undefined;
27507 }
27508
27509 // do not re-compile schemas
27510 if (schema.__$compiled) {
27511 return true;
27512 }
27513
27514 if (schema.id && typeof schema.id === "string") {
27515 // add this to our schemaCache (before compilation in case we have references including id)
27516 SchemaCache.cacheSchemaByUri.call(this, schema.id, schema);
27517 }
27518
27519 // this method can be called recursively, so we need to remember our root
27520 var isRoot = false;
27521 if (!report.rootSchema) {
27522 report.rootSchema = schema;
27523 isRoot = true;
27524 }
27525
27526 // delete all __$missingReferences from previous compilation attempts
27527 var isValidExceptReferences = report.isValid();
27528 delete schema.__$missingReferences;
27529
27530 // collect all references that need to be resolved - $ref and $schema
27531 var refs = collectReferences.call(this, schema),
27532 idx = refs.length;
27533 while (idx--) {
27534 // resolve all the collected references into __xxxResolved pointer
27535 var refObj = refs[idx];
27536 var response = SchemaCache.getSchemaByUri.call(this, report, refObj.ref, schema);
27537
27538 // we can try to use custom schemaReader if available
27539 if (!response) {
27540 var schemaReader = this.getSchemaReader();
27541 if (schemaReader) {
27542 // it's supposed to return a valid schema
27543 var s = schemaReader(refObj.ref);
27544 if (s) {
27545 // it needs to have the id
27546 s.id = refObj.ref;
27547 // try to compile the schema
27548 var subreport = new Report(report);
27549 if (!exports.compileSchema.call(this, subreport, s)) {
27550 // copy errors to report
27551 report.errors = report.errors.concat(subreport.errors);
27552 } else {
27553 response = SchemaCache.getSchemaByUri.call(this, report, refObj.ref, schema);
27554 }
27555 }
27556 }
27557 }
27558
27559 if (!response) {
27560
27561 var hasNotValid = report.hasError("REMOTE_NOT_VALID", [refObj.ref]);
27562 var isAbsolute = Utils.isAbsoluteUri(refObj.ref);
27563 var isDownloaded = false;
27564 var ignoreUnresolvableRemotes = this.options.ignoreUnresolvableReferences === true;
27565
27566 if (isAbsolute) {
27567 // we shouldn't add UNRESOLVABLE_REFERENCE for schemas we already have downloaded
27568 // and set through setRemoteReference method
27569 isDownloaded = SchemaCache.checkCacheForUri.call(this, refObj.ref);
27570 }
27571
27572 if (hasNotValid) {
27573 // already has REMOTE_NOT_VALID error for this one
27574 } else if (ignoreUnresolvableRemotes && isAbsolute) {
27575 // ignoreUnresolvableRemotes is on and remote isAbsolute
27576 } else if (isDownloaded) {
27577 // remote is downloaded, so no UNRESOLVABLE_REFERENCE
27578 } else {
27579 Array.prototype.push.apply(report.path, refObj.path);
27580 report.addError("UNRESOLVABLE_REFERENCE", [refObj.ref]);
27581 report.path = report.path.slice(0, -refObj.path.length);
27582
27583 // pusblish unresolved references out
27584 if (isValidExceptReferences) {
27585 schema.__$missingReferences = schema.__$missingReferences || [];
27586 schema.__$missingReferences.push(refObj);
27587 }
27588 }
27589 }
27590 // this might create circular references
27591 refObj.obj["__" + refObj.key + "Resolved"] = response;
27592 }
27593
27594 var isValid = report.isValid();
27595 if (isValid) {
27596 schema.__$compiled = true;
27597 } else {
27598 if (schema.id && typeof schema.id === "string") {
27599 // remove this schema from schemaCache because it failed to compile
27600 SchemaCache.removeFromCacheByUri.call(this, schema.id);
27601 }
27602 }
27603
27604 // we don't need the root pointer anymore
27605 if (isRoot) {
27606 report.rootSchema = undefined;
27607 }
27608
27609 return isValid;
27610
27611};
27612
27613},{"./Report":236,"./SchemaCache":237,"./Utils":240}],239:[function(require,module,exports){
27614"use strict";
27615
27616var FormatValidators = require("./FormatValidators"),
27617 JsonValidation = require("./JsonValidation"),
27618 Report = require("./Report"),
27619 Utils = require("./Utils");
27620
27621var SchemaValidators = {
27622 $ref: function (report, schema) {
27623 // http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
27624 // http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03
27625 if (typeof schema.$ref !== "string") {
27626 report.addError("KEYWORD_TYPE_EXPECTED", ["$ref", "string"]);
27627 }
27628 },
27629 $schema: function (report, schema) {
27630 // http://json-schema.org/latest/json-schema-core.html#rfc.section.6
27631 if (typeof schema.$schema !== "string") {
27632 report.addError("KEYWORD_TYPE_EXPECTED", ["$schema", "string"]);
27633 }
27634 },
27635 multipleOf: function (report, schema) {
27636 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.1.1
27637 if (typeof schema.multipleOf !== "number") {
27638 report.addError("KEYWORD_TYPE_EXPECTED", ["multipleOf", "number"]);
27639 } else if (schema.multipleOf <= 0) {
27640 report.addError("KEYWORD_MUST_BE", ["multipleOf", "strictly greater than 0"]);
27641 }
27642 },
27643 maximum: function (report, schema) {
27644 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.2.1
27645 if (typeof schema.maximum !== "number") {
27646 report.addError("KEYWORD_TYPE_EXPECTED", ["maximum", "number"]);
27647 }
27648 },
27649 exclusiveMaximum: function (report, schema) {
27650 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.2.1
27651 if (typeof schema.exclusiveMaximum !== "boolean") {
27652 report.addError("KEYWORD_TYPE_EXPECTED", ["exclusiveMaximum", "boolean"]);
27653 } else if (schema.maximum === undefined) {
27654 report.addError("KEYWORD_DEPENDENCY", ["exclusiveMaximum", "maximum"]);
27655 }
27656 },
27657 minimum: function (report, schema) {
27658 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.3.1
27659 if (typeof schema.minimum !== "number") {
27660 report.addError("KEYWORD_TYPE_EXPECTED", ["minimum", "number"]);
27661 }
27662 },
27663 exclusiveMinimum: function (report, schema) {
27664 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.1.3.1
27665 if (typeof schema.exclusiveMinimum !== "boolean") {
27666 report.addError("KEYWORD_TYPE_EXPECTED", ["exclusiveMinimum", "boolean"]);
27667 } else if (schema.minimum === undefined) {
27668 report.addError("KEYWORD_DEPENDENCY", ["exclusiveMinimum", "minimum"]);
27669 }
27670 },
27671 maxLength: function (report, schema) {
27672 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1.1
27673 if (Utils.whatIs(schema.maxLength) !== "integer") {
27674 report.addError("KEYWORD_TYPE_EXPECTED", ["maxLength", "integer"]);
27675 } else if (schema.maxLength < 0) {
27676 report.addError("KEYWORD_MUST_BE", ["maxLength", "greater than, or equal to 0"]);
27677 }
27678 },
27679 minLength: function (report, schema) {
27680 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.2.1
27681 if (Utils.whatIs(schema.minLength) !== "integer") {
27682 report.addError("KEYWORD_TYPE_EXPECTED", ["minLength", "integer"]);
27683 } else if (schema.minLength < 0) {
27684 report.addError("KEYWORD_MUST_BE", ["minLength", "greater than, or equal to 0"]);
27685 }
27686 },
27687 pattern: function (report, schema) {
27688 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.3.1
27689 if (typeof schema.pattern !== "string") {
27690 report.addError("KEYWORD_TYPE_EXPECTED", ["pattern", "string"]);
27691 } else {
27692 try {
27693 RegExp(schema.pattern);
27694 } catch (e) {
27695 report.addError("KEYWORD_PATTERN", ["pattern", schema.pattern]);
27696 }
27697 }
27698 },
27699 additionalItems: function (report, schema) {
27700 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.1.1
27701 var type = Utils.whatIs(schema.additionalItems);
27702 if (type !== "boolean" && type !== "object") {
27703 report.addError("KEYWORD_TYPE_EXPECTED", ["additionalItems", ["boolean", "object"]]);
27704 } else if (type === "object") {
27705 report.path.push("additionalItems");
27706 exports.validateSchema.call(this, report, schema.additionalItems);
27707 report.path.pop();
27708 }
27709 },
27710 items: function (report, schema) {
27711 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.1.1
27712 var type = Utils.whatIs(schema.items);
27713
27714 if (type === "object") {
27715 report.path.push("items");
27716 exports.validateSchema.call(this, report, schema.items);
27717 report.path.pop();
27718 } else if (type === "array") {
27719 var idx = schema.items.length;
27720 while (idx--) {
27721 report.path.push("items");
27722 report.path.push(idx.toString());
27723 exports.validateSchema.call(this, report, schema.items[idx]);
27724 report.path.pop();
27725 report.path.pop();
27726 }
27727 } else {
27728 report.addError("KEYWORD_TYPE_EXPECTED", ["items", ["array", "object"]]);
27729 }
27730
27731 // custom - strict mode
27732 if (this.options.forceAdditional === true && schema.additionalItems === undefined && Array.isArray(schema.items)) {
27733 report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalItems"]);
27734 }
27735 // custome - assume defined false mode
27736 if (this.options.assumeAdditional && schema.additionalItems === undefined && Array.isArray(schema.items)) {
27737 schema.additionalItems = false;
27738 }
27739 },
27740 maxItems: function (report, schema) {
27741 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.2.1
27742 if (typeof schema.maxItems !== "number") {
27743 report.addError("KEYWORD_TYPE_EXPECTED", ["maxItems", "integer"]);
27744 } else if (schema.maxItems < 0) {
27745 report.addError("KEYWORD_MUST_BE", ["maxItems", "greater than, or equal to 0"]);
27746 }
27747 },
27748 minItems: function (report, schema) {
27749 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.3.1
27750 if (Utils.whatIs(schema.minItems) !== "integer") {
27751 report.addError("KEYWORD_TYPE_EXPECTED", ["minItems", "integer"]);
27752 } else if (schema.minItems < 0) {
27753 report.addError("KEYWORD_MUST_BE", ["minItems", "greater than, or equal to 0"]);
27754 }
27755 },
27756 uniqueItems: function (report, schema) {
27757 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.4.1
27758 if (typeof schema.uniqueItems !== "boolean") {
27759 report.addError("KEYWORD_TYPE_EXPECTED", ["uniqueItems", "boolean"]);
27760 }
27761 },
27762 maxProperties: function (report, schema) {
27763 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.1.1
27764 if (Utils.whatIs(schema.maxProperties) !== "integer") {
27765 report.addError("KEYWORD_TYPE_EXPECTED", ["maxProperties", "integer"]);
27766 } else if (schema.maxProperties < 0) {
27767 report.addError("KEYWORD_MUST_BE", ["maxProperties", "greater than, or equal to 0"]);
27768 }
27769 },
27770 minProperties: function (report, schema) {
27771 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.2.1
27772 if (Utils.whatIs(schema.minProperties) !== "integer") {
27773 report.addError("KEYWORD_TYPE_EXPECTED", ["minProperties", "integer"]);
27774 } else if (schema.minProperties < 0) {
27775 report.addError("KEYWORD_MUST_BE", ["minProperties", "greater than, or equal to 0"]);
27776 }
27777 },
27778 required: function (report, schema) {
27779 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.3.1
27780 if (Utils.whatIs(schema.required) !== "array") {
27781 report.addError("KEYWORD_TYPE_EXPECTED", ["required", "array"]);
27782 } else if (schema.required.length === 0) {
27783 report.addError("KEYWORD_MUST_BE", ["required", "an array with at least one element"]);
27784 } else {
27785 var idx = schema.required.length;
27786 while (idx--) {
27787 if (typeof schema.required[idx] !== "string") {
27788 report.addError("KEYWORD_VALUE_TYPE", ["required", "string"]);
27789 }
27790 }
27791 if (Utils.isUniqueArray(schema.required) === false) {
27792 report.addError("KEYWORD_MUST_BE", ["required", "an array with unique items"]);
27793 }
27794 }
27795 },
27796 additionalProperties: function (report, schema) {
27797 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.1
27798 var type = Utils.whatIs(schema.additionalProperties);
27799 if (type !== "boolean" && type !== "object") {
27800 report.addError("KEYWORD_TYPE_EXPECTED", ["additionalProperties", ["boolean", "object"]]);
27801 } else if (type === "object") {
27802 report.path.push("additionalProperties");
27803 exports.validateSchema.call(this, report, schema.additionalProperties);
27804 report.path.pop();
27805 }
27806 },
27807 properties: function (report, schema) {
27808 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.1
27809 if (Utils.whatIs(schema.properties) !== "object") {
27810 report.addError("KEYWORD_TYPE_EXPECTED", ["properties", "object"]);
27811 return;
27812 }
27813
27814 var keys = Object.keys(schema.properties),
27815 idx = keys.length;
27816 while (idx--) {
27817 var key = keys[idx],
27818 val = schema.properties[key];
27819 report.path.push("properties");
27820 report.path.push(key);
27821 exports.validateSchema.call(this, report, val);
27822 report.path.pop();
27823 report.path.pop();
27824 }
27825
27826 // custom - strict mode
27827 if (this.options.forceAdditional === true && schema.additionalProperties === undefined) {
27828 report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalProperties"]);
27829 }
27830 // custome - assume defined false mode
27831 if (this.options.assumeAdditional && schema.additionalProperties === undefined) {
27832 schema.additionalProperties = false;
27833 }
27834 // custom - forceProperties
27835 if (this.options.forceProperties === true && keys.length === 0) {
27836 report.addError("CUSTOM_MODE_FORCE_PROPERTIES", ["properties"]);
27837 }
27838 },
27839 patternProperties: function (report, schema) {
27840 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.4.1
27841 if (Utils.whatIs(schema.patternProperties) !== "object") {
27842 report.addError("KEYWORD_TYPE_EXPECTED", ["patternProperties", "object"]);
27843 return;
27844 }
27845
27846 var keys = Object.keys(schema.patternProperties),
27847 idx = keys.length;
27848 while (idx--) {
27849 var key = keys[idx],
27850 val = schema.patternProperties[key];
27851 try {
27852 RegExp(key);
27853 } catch (e) {
27854 report.addError("KEYWORD_PATTERN", ["patternProperties", key]);
27855 }
27856 report.path.push("patternProperties");
27857 report.path.push(key.toString());
27858 exports.validateSchema.call(this, report, val);
27859 report.path.pop();
27860 report.path.pop();
27861 }
27862
27863 // custom - forceProperties
27864 if (this.options.forceProperties === true && keys.length === 0) {
27865 report.addError("CUSTOM_MODE_FORCE_PROPERTIES", ["patternProperties"]);
27866 }
27867 },
27868 dependencies: function (report, schema) {
27869 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.4.5.1
27870 if (Utils.whatIs(schema.dependencies) !== "object") {
27871 report.addError("KEYWORD_TYPE_EXPECTED", ["dependencies", "object"]);
27872 } else {
27873 var keys = Object.keys(schema.dependencies),
27874 idx = keys.length;
27875 while (idx--) {
27876 var schemaKey = keys[idx],
27877 schemaDependency = schema.dependencies[schemaKey],
27878 type = Utils.whatIs(schemaDependency);
27879
27880 if (type === "object") {
27881 report.path.push("dependencies");
27882 report.path.push(schemaKey);
27883 exports.validateSchema.call(this, report, schemaDependency);
27884 report.path.pop();
27885 report.path.pop();
27886 } else if (type === "array") {
27887 var idx2 = schemaDependency.length;
27888 if (idx2 === 0) {
27889 report.addError("KEYWORD_MUST_BE", ["dependencies", "not empty array"]);
27890 }
27891 while (idx2--) {
27892 if (typeof schemaDependency[idx2] !== "string") {
27893 report.addError("KEYWORD_VALUE_TYPE", ["dependensices", "string"]);
27894 }
27895 }
27896 if (Utils.isUniqueArray(schemaDependency) === false) {
27897 report.addError("KEYWORD_MUST_BE", ["dependencies", "an array with unique items"]);
27898 }
27899 } else {
27900 report.addError("KEYWORD_VALUE_TYPE", ["dependencies", "object or array"]);
27901 }
27902 }
27903 }
27904 },
27905 enum: function (report, schema) {
27906 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.1.1
27907 if (Array.isArray(schema.enum) === false) {
27908 report.addError("KEYWORD_TYPE_EXPECTED", ["enum", "array"]);
27909 } else if (schema.enum.length === 0) {
27910 report.addError("KEYWORD_MUST_BE", ["enum", "an array with at least one element"]);
27911 } else if (Utils.isUniqueArray(schema.enum) === false) {
27912 report.addError("KEYWORD_MUST_BE", ["enum", "an array with unique elements"]);
27913 }
27914 },
27915 type: function (report, schema) {
27916 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.2.1
27917 var primitiveTypes = ["array", "boolean", "integer", "number", "null", "object", "string"],
27918 primitiveTypeStr = primitiveTypes.join(","),
27919 isArray = Array.isArray(schema.type);
27920
27921 if (isArray) {
27922 var idx = schema.type.length;
27923 while (idx--) {
27924 if (primitiveTypes.indexOf(schema.type[idx]) === -1) {
27925 report.addError("KEYWORD_TYPE_EXPECTED", ["type", primitiveTypeStr]);
27926 }
27927 }
27928 if (Utils.isUniqueArray(schema.type) === false) {
27929 report.addError("KEYWORD_MUST_BE", ["type", "an object with unique properties"]);
27930 }
27931 } else if (typeof schema.type === "string") {
27932 if (primitiveTypes.indexOf(schema.type) === -1) {
27933 report.addError("KEYWORD_TYPE_EXPECTED", ["type", primitiveTypeStr]);
27934 }
27935 } else {
27936 report.addError("KEYWORD_TYPE_EXPECTED", ["type", ["string", "array"]]);
27937 }
27938
27939 if (this.options.noEmptyStrings === true) {
27940 if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
27941 if (schema.minLength === undefined &&
27942 schema.enum === undefined &&
27943 schema.format === undefined) {
27944
27945 schema.minLength = 1;
27946 }
27947 }
27948 }
27949 if (this.options.noEmptyArrays === true) {
27950 if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
27951 if (schema.minItems === undefined) {
27952 schema.minItems = 1;
27953 }
27954 }
27955 }
27956 if (this.options.forceProperties === true) {
27957 if (schema.type === "object" || isArray && schema.type.indexOf("object") !== -1) {
27958 if (schema.properties === undefined && schema.patternProperties === undefined) {
27959 report.addError("KEYWORD_UNDEFINED_STRICT", ["properties"]);
27960 }
27961 }
27962 }
27963 if (this.options.forceItems === true) {
27964 if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
27965 if (schema.items === undefined) {
27966 report.addError("KEYWORD_UNDEFINED_STRICT", ["items"]);
27967 }
27968 }
27969 }
27970 if (this.options.forceMinItems === true) {
27971 if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
27972 if (schema.minItems === undefined) {
27973 report.addError("KEYWORD_UNDEFINED_STRICT", ["minItems"]);
27974 }
27975 }
27976 }
27977 if (this.options.forceMaxItems === true) {
27978 if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
27979 if (schema.maxItems === undefined) {
27980 report.addError("KEYWORD_UNDEFINED_STRICT", ["maxItems"]);
27981 }
27982 }
27983 }
27984 if (this.options.forceMinLength === true) {
27985 if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
27986 if (schema.minLength === undefined &&
27987 schema.format === undefined &&
27988 schema.enum === undefined &&
27989 schema.pattern === undefined) {
27990 report.addError("KEYWORD_UNDEFINED_STRICT", ["minLength"]);
27991 }
27992 }
27993 }
27994 if (this.options.forceMaxLength === true) {
27995 if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
27996 if (schema.maxLength === undefined &&
27997 schema.format === undefined &&
27998 schema.enum === undefined &&
27999 schema.pattern === undefined) {
28000 report.addError("KEYWORD_UNDEFINED_STRICT", ["maxLength"]);
28001 }
28002 }
28003 }
28004 },
28005 allOf: function (report, schema) {
28006 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.3.1
28007 if (Array.isArray(schema.allOf) === false) {
28008 report.addError("KEYWORD_TYPE_EXPECTED", ["allOf", "array"]);
28009 } else if (schema.allOf.length === 0) {
28010 report.addError("KEYWORD_MUST_BE", ["allOf", "an array with at least one element"]);
28011 } else {
28012 var idx = schema.allOf.length;
28013 while (idx--) {
28014 report.path.push("allOf");
28015 report.path.push(idx.toString());
28016 exports.validateSchema.call(this, report, schema.allOf[idx]);
28017 report.path.pop();
28018 report.path.pop();
28019 }
28020 }
28021 },
28022 anyOf: function (report, schema) {
28023 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.4.1
28024 if (Array.isArray(schema.anyOf) === false) {
28025 report.addError("KEYWORD_TYPE_EXPECTED", ["anyOf", "array"]);
28026 } else if (schema.anyOf.length === 0) {
28027 report.addError("KEYWORD_MUST_BE", ["anyOf", "an array with at least one element"]);
28028 } else {
28029 var idx = schema.anyOf.length;
28030 while (idx--) {
28031 report.path.push("anyOf");
28032 report.path.push(idx.toString());
28033 exports.validateSchema.call(this, report, schema.anyOf[idx]);
28034 report.path.pop();
28035 report.path.pop();
28036 }
28037 }
28038 },
28039 oneOf: function (report, schema) {
28040 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.5.1
28041 if (Array.isArray(schema.oneOf) === false) {
28042 report.addError("KEYWORD_TYPE_EXPECTED", ["oneOf", "array"]);
28043 } else if (schema.oneOf.length === 0) {
28044 report.addError("KEYWORD_MUST_BE", ["oneOf", "an array with at least one element"]);
28045 } else {
28046 var idx = schema.oneOf.length;
28047 while (idx--) {
28048 report.path.push("oneOf");
28049 report.path.push(idx.toString());
28050 exports.validateSchema.call(this, report, schema.oneOf[idx]);
28051 report.path.pop();
28052 report.path.pop();
28053 }
28054 }
28055 },
28056 not: function (report, schema) {
28057 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.6.1
28058 if (Utils.whatIs(schema.not) !== "object") {
28059 report.addError("KEYWORD_TYPE_EXPECTED", ["not", "object"]);
28060 } else {
28061 report.path.push("not");
28062 exports.validateSchema.call(this, report, schema.not);
28063 report.path.pop();
28064 }
28065 },
28066 definitions: function (report, schema) {
28067 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.5.7.1
28068 if (Utils.whatIs(schema.definitions) !== "object") {
28069 report.addError("KEYWORD_TYPE_EXPECTED", ["definitions", "object"]);
28070 } else {
28071 var keys = Object.keys(schema.definitions),
28072 idx = keys.length;
28073 while (idx--) {
28074 var key = keys[idx],
28075 val = schema.definitions[key];
28076 report.path.push("definitions");
28077 report.path.push(key);
28078 exports.validateSchema.call(this, report, val);
28079 report.path.pop();
28080 report.path.pop();
28081 }
28082 }
28083 },
28084 format: function (report, schema) {
28085 if (typeof schema.format !== "string") {
28086 report.addError("KEYWORD_TYPE_EXPECTED", ["format", "string"]);
28087 } else {
28088 if (FormatValidators[schema.format] === undefined && this.options.ignoreUnknownFormats !== true) {
28089 report.addError("UNKNOWN_FORMAT", [schema.format]);
28090 }
28091 }
28092 },
28093 id: function (report, schema) {
28094 // http://json-schema.org/latest/json-schema-core.html#rfc.section.7.2
28095 if (typeof schema.id !== "string") {
28096 report.addError("KEYWORD_TYPE_EXPECTED", ["id", "string"]);
28097 }
28098 },
28099 title: function (report, schema) {
28100 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1
28101 if (typeof schema.title !== "string") {
28102 report.addError("KEYWORD_TYPE_EXPECTED", ["title", "string"]);
28103 }
28104 },
28105 description: function (report, schema) {
28106 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1
28107 if (typeof schema.description !== "string") {
28108 report.addError("KEYWORD_TYPE_EXPECTED", ["description", "string"]);
28109 }
28110 },
28111 "default": function (/* report, schema */) {
28112 // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2
28113 // There are no restrictions placed on the value of this keyword.
28114 }
28115};
28116
28117/**
28118 *
28119 * @param {Report} report
28120 * @param {*[]} arr
28121 *
28122 * @returns {boolean}
28123 */
28124var validateArrayOfSchemas = function (report, arr) {
28125 var idx = arr.length;
28126 while (idx--) {
28127 exports.validateSchema.call(this, report, arr[idx]);
28128 }
28129 return report.isValid();
28130};
28131
28132/**
28133 *
28134 * @param {Report} report
28135 * @param {*} schema
28136 */
28137exports.validateSchema = function (report, schema) {
28138
28139 report.commonErrorMessage = "SCHEMA_VALIDATION_FAILED";
28140
28141 // if schema is an array, assume it's an array of schemas
28142 if (Array.isArray(schema)) {
28143 return validateArrayOfSchemas.call(this, report, schema);
28144 }
28145
28146 // do not revalidate schema that has already been validated once
28147 if (schema.__$validated) {
28148 return true;
28149 }
28150
28151 // if $schema is present, this schema should validate against that $schema
28152 var hasParentSchema = schema.$schema && schema.id !== schema.$schema;
28153 if (hasParentSchema) {
28154 if (schema.__$schemaResolved && schema.__$schemaResolved !== schema) {
28155 var subReport = new Report(report);
28156 var valid = JsonValidation.validate.call(this, subReport, schema.__$schemaResolved, schema);
28157 if (valid === false) {
28158 report.addError("PARENT_SCHEMA_VALIDATION_FAILED", null, subReport);
28159 }
28160 } else {
28161 if (this.options.ignoreUnresolvableReferences !== true) {
28162 report.addError("REF_UNRESOLVED", [schema.$schema]);
28163 }
28164 }
28165 }
28166
28167 if (this.options.noTypeless === true) {
28168 // issue #36 - inherit type to anyOf, oneOf, allOf if noTypeless is defined
28169 if (schema.type !== undefined) {
28170 var schemas = [];
28171 if (Array.isArray(schema.anyOf)) { schemas = schemas.concat(schema.anyOf); }
28172 if (Array.isArray(schema.oneOf)) { schemas = schemas.concat(schema.oneOf); }
28173 if (Array.isArray(schema.allOf)) { schemas = schemas.concat(schema.allOf); }
28174 schemas.forEach(function (sch) {
28175 if (!sch.type) { sch.type = schema.type; }
28176 });
28177 }
28178 // end issue #36
28179 if (schema.enum === undefined &&
28180 schema.type === undefined &&
28181 schema.anyOf === undefined &&
28182 schema.oneOf === undefined &&
28183 schema.not === undefined &&
28184 schema.$ref === undefined) {
28185 report.addError("KEYWORD_UNDEFINED_STRICT", ["type"]);
28186 }
28187 }
28188
28189 var keys = Object.keys(schema),
28190 idx = keys.length;
28191 while (idx--) {
28192 var key = keys[idx];
28193 if (key.indexOf("__") === 0) { continue; }
28194 if (SchemaValidators[key] !== undefined) {
28195 SchemaValidators[key].call(this, report, schema);
28196 } else if (!hasParentSchema) {
28197 if (this.options.noExtraKeywords === true) {
28198 report.addError("KEYWORD_UNEXPECTED", [key]);
28199 }
28200 }
28201 }
28202
28203 if (this.options.pedanticCheck === true) {
28204 if (schema.enum) {
28205 // break recursion
28206 var tmpSchema = Utils.clone(schema);
28207 delete tmpSchema.enum;
28208 delete tmpSchema.default;
28209
28210 report.path.push("enum");
28211 idx = schema.enum.length;
28212 while (idx--) {
28213 report.path.push(idx.toString());
28214 JsonValidation.validate.call(this, report, tmpSchema, schema.enum[idx]);
28215 report.path.pop();
28216 }
28217 report.path.pop();
28218 }
28219
28220 if (schema.default) {
28221 report.path.push("default");
28222 JsonValidation.validate.call(this, report, schema, schema.default);
28223 report.path.pop();
28224 }
28225 }
28226
28227 var isValid = report.isValid();
28228 if (isValid) {
28229 schema.__$validated = true;
28230 }
28231 return isValid;
28232};
28233
28234},{"./FormatValidators":233,"./JsonValidation":234,"./Report":236,"./Utils":240}],240:[function(require,module,exports){
28235"use strict";
28236
28237require("core-js/es6/symbol");
28238
28239exports.jsonSymbol = Symbol.for("z-schema/json");
28240
28241exports.schemaSymbol = Symbol.for("z-schema/schema");
28242
28243/**
28244 * @param {object} obj
28245 *
28246 * @returns {string[]}
28247 */
28248var sortedKeys = exports.sortedKeys = function (obj) {
28249 return Object.keys(obj).sort();
28250};
28251
28252/**
28253 *
28254 * @param {string} uri
28255 *
28256 * @returns {boolean}
28257 */
28258exports.isAbsoluteUri = function (uri) {
28259 return /^https?:\/\//.test(uri);
28260};
28261
28262/**
28263 *
28264 * @param {string} uri
28265 *
28266 * @returns {boolean}
28267 */
28268exports.isRelativeUri = function (uri) {
28269 // relative URIs that end with a hash sign, issue #56
28270 return /.+#/.test(uri);
28271};
28272
28273exports.whatIs = function (what) {
28274
28275 var to = typeof what;
28276
28277 if (to === "object") {
28278 if (what === null) {
28279 return "null";
28280 }
28281 if (Array.isArray(what)) {
28282 return "array";
28283 }
28284 return "object"; // typeof what === 'object' && what === Object(what) && !Array.isArray(what);
28285 }
28286
28287 if (to === "number") {
28288 if (Number.isFinite(what)) {
28289 if (what % 1 === 0) {
28290 return "integer";
28291 } else {
28292 return "number";
28293 }
28294 }
28295 if (Number.isNaN(what)) {
28296 return "not-a-number";
28297 }
28298 return "unknown-number";
28299 }
28300
28301 return to; // undefined, boolean, string, function
28302
28303};
28304
28305/**
28306 *
28307 * @param {*} json1
28308 * @param {*} json2
28309 * @param {*} [options]
28310 *
28311 * @returns {boolean}
28312 */
28313exports.areEqual = function areEqual(json1, json2, options) {
28314
28315 options = options || {};
28316 var caseInsensitiveComparison = options.caseInsensitiveComparison || false;
28317
28318 // http://json-schema.org/latest/json-schema-core.html#rfc.section.3.6
28319
28320 // Two JSON values are said to be equal if and only if:
28321 // both are nulls; or
28322 // both are booleans, and have the same value; or
28323 // both are strings, and have the same value; or
28324 // both are numbers, and have the same mathematical value; or
28325 if (json1 === json2) {
28326 return true;
28327 }
28328 if (
28329 caseInsensitiveComparison === true &&
28330 typeof json1 === "string" && typeof json2 === "string" &&
28331 json1.toUpperCase() === json2.toUpperCase()) {
28332 return true;
28333 }
28334
28335 var i, len;
28336
28337 // both are arrays, and:
28338 if (Array.isArray(json1) && Array.isArray(json2)) {
28339 // have the same number of items; and
28340 if (json1.length !== json2.length) {
28341 return false;
28342 }
28343 // items at the same index are equal according to this definition; or
28344 len = json1.length;
28345 for (i = 0; i < len; i++) {
28346 if (!areEqual(json1[i], json2[i], { caseInsensitiveComparison: caseInsensitiveComparison })) {
28347 return false;
28348 }
28349 }
28350 return true;
28351 }
28352
28353 // both are objects, and:
28354 if (exports.whatIs(json1) === "object" && exports.whatIs(json2) === "object") {
28355 // have the same set of property names; and
28356 var keys1 = sortedKeys(json1);
28357 var keys2 = sortedKeys(json2);
28358 if (!areEqual(keys1, keys2, { caseInsensitiveComparison: caseInsensitiveComparison })) {
28359 return false;
28360 }
28361 // values for a same property name are equal according to this definition.
28362 len = keys1.length;
28363 for (i = 0; i < len; i++) {
28364 if (!areEqual(json1[keys1[i]], json2[keys1[i]], { caseInsensitiveComparison: caseInsensitiveComparison })) {
28365 return false;
28366 }
28367 }
28368 return true;
28369 }
28370
28371 return false;
28372};
28373
28374/**
28375 *
28376 * @param {*[]} arr
28377 * @param {number[]} [indexes]
28378 *
28379 * @returns {boolean}
28380 */
28381exports.isUniqueArray = function (arr, indexes) {
28382 var i, j, l = arr.length;
28383 for (i = 0; i < l; i++) {
28384 for (j = i + 1; j < l; j++) {
28385 if (exports.areEqual(arr[i], arr[j])) {
28386 if (indexes) { indexes.push(i, j); }
28387 return false;
28388 }
28389 }
28390 }
28391 return true;
28392};
28393
28394/**
28395 *
28396 * @param {*} bigSet
28397 * @param {*} subSet
28398 *
28399 * @returns {*[]}
28400 */
28401exports.difference = function (bigSet, subSet) {
28402 var arr = [],
28403 idx = bigSet.length;
28404 while (idx--) {
28405 if (subSet.indexOf(bigSet[idx]) === -1) {
28406 arr.push(bigSet[idx]);
28407 }
28408 }
28409 return arr;
28410};
28411
28412// NOT a deep version of clone
28413exports.clone = function (src) {
28414 if (typeof src === "undefined") { return void 0; }
28415 if (typeof src !== "object" || src === null) { return src; }
28416 var res, idx;
28417 if (Array.isArray(src)) {
28418 res = [];
28419 idx = src.length;
28420 while (idx--) {
28421 res[idx] = src[idx];
28422 }
28423 } else {
28424 res = {};
28425 var keys = Object.keys(src);
28426 idx = keys.length;
28427 while (idx--) {
28428 var key = keys[idx];
28429 res[key] = src[key];
28430 }
28431 }
28432 return res;
28433};
28434
28435exports.cloneDeep = function (src) {
28436 var visited = [], cloned = [];
28437 function cloneDeep(src) {
28438 if (typeof src !== "object" || src === null) { return src; }
28439 var res, idx, cidx;
28440
28441 cidx = visited.indexOf(src);
28442 if (cidx !== -1) { return cloned[cidx]; }
28443
28444 visited.push(src);
28445 if (Array.isArray(src)) {
28446 res = [];
28447 cloned.push(res);
28448 idx = src.length;
28449 while (idx--) {
28450 res[idx] = cloneDeep(src[idx]);
28451 }
28452 } else {
28453 res = {};
28454 cloned.push(res);
28455 var keys = Object.keys(src);
28456 idx = keys.length;
28457 while (idx--) {
28458 var key = keys[idx];
28459 res[key] = cloneDeep(src[key]);
28460 }
28461 }
28462 return res;
28463 }
28464 return cloneDeep(src);
28465};
28466
28467/*
28468 following function comes from punycode.js library
28469 see: https://github.com/bestiejs/punycode.js
28470*/
28471/*jshint -W016*/
28472/**
28473 * Creates an array containing the numeric code points of each Unicode
28474 * character in the string. While JavaScript uses UCS-2 internally,
28475 * this function will convert a pair of surrogate halves (each of which
28476 * UCS-2 exposes as separate characters) into a single code point,
28477 * matching UTF-16.
28478 * @see `punycode.ucs2.encode`
28479 * @see <https://mathiasbynens.be/notes/javascript-encoding>
28480 * @memberOf punycode.ucs2
28481 * @name decode
28482 * @param {String} string The Unicode input string (UCS-2).
28483 * @returns {Array} The new array of code points.
28484 */
28485exports.ucs2decode = function (string) {
28486 var output = [],
28487 counter = 0,
28488 length = string.length,
28489 value,
28490 extra;
28491 while (counter < length) {
28492 value = string.charCodeAt(counter++);
28493 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
28494 // high surrogate, and there is a next character
28495 extra = string.charCodeAt(counter++);
28496 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
28497 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
28498 } else {
28499 // unmatched surrogate; only append this code unit, in case the next
28500 // code unit is the high surrogate of a surrogate pair
28501 output.push(value);
28502 counter--;
28503 }
28504 } else {
28505 output.push(value);
28506 }
28507 }
28508 return output;
28509};
28510/*jshint +W016*/
28511
28512},{"core-js/es6/symbol":12}],241:[function(require,module,exports){
28513(function (process){
28514"use strict";
28515
28516require("./Polyfills");
28517var get = require("lodash.get");
28518var Report = require("./Report");
28519var FormatValidators = require("./FormatValidators");
28520var JsonValidation = require("./JsonValidation");
28521var SchemaCache = require("./SchemaCache");
28522var SchemaCompilation = require("./SchemaCompilation");
28523var SchemaValidation = require("./SchemaValidation");
28524var Utils = require("./Utils");
28525var Draft4Schema = require("./schemas/schema.json");
28526var Draft4HyperSchema = require("./schemas/hyper-schema.json");
28527
28528/**
28529 * default options
28530 */
28531var defaultOptions = {
28532 // default timeout for all async tasks
28533 asyncTimeout: 2000,
28534 // force additionalProperties and additionalItems to be defined on "object" and "array" types
28535 forceAdditional: false,
28536 // assume additionalProperties and additionalItems are defined as "false" where appropriate
28537 assumeAdditional: false,
28538 // do case insensitive comparison for enums
28539 enumCaseInsensitiveComparison: false,
28540 // force items to be defined on "array" types
28541 forceItems: false,
28542 // force minItems to be defined on "array" types
28543 forceMinItems: false,
28544 // force maxItems to be defined on "array" types
28545 forceMaxItems: false,
28546 // force minLength to be defined on "string" types
28547 forceMinLength: false,
28548 // force maxLength to be defined on "string" types
28549 forceMaxLength: false,
28550 // force properties or patternProperties to be defined on "object" types
28551 forceProperties: false,
28552 // ignore references that cannot be resolved (remote schemas) // TODO: make sure this is only for remote schemas, not local ones
28553 ignoreUnresolvableReferences: false,
28554 // disallow usage of keywords that this validator can't handle
28555 noExtraKeywords: false,
28556 // disallow usage of schema's without "type" defined
28557 noTypeless: false,
28558 // disallow zero length strings in validated objects
28559 noEmptyStrings: false,
28560 // disallow zero length arrays in validated objects
28561 noEmptyArrays: false,
28562 // forces "uri" format to be in fully rfc3986 compliant
28563 strictUris: false,
28564 // turn on some of the above
28565 strictMode: false,
28566 // report error paths as an array of path segments to get to the offending node
28567 reportPathAsArray: false,
28568 // stops validation as soon as an error is found, true by default but can be turned off
28569 breakOnFirstError: true,
28570 // check if schema follow best practices and common sence
28571 pedanticCheck: false,
28572 // ignore unknown formats (do not report them as an error)
28573 ignoreUnknownFormats: false,
28574 // function to be called on every schema
28575 customValidator: null
28576};
28577
28578function normalizeOptions(options) {
28579 var normalized;
28580
28581 // options
28582 if (typeof options === "object") {
28583 var keys = Object.keys(options),
28584 idx = keys.length,
28585 key;
28586
28587 // check that the options are correctly configured
28588 while (idx--) {
28589 key = keys[idx];
28590 if (defaultOptions[key] === undefined) {
28591 throw new Error("Unexpected option passed to constructor: " + key);
28592 }
28593 }
28594
28595 // copy the default options into passed options
28596 keys = Object.keys(defaultOptions);
28597 idx = keys.length;
28598 while (idx--) {
28599 key = keys[idx];
28600 if (options[key] === undefined) {
28601 options[key] = Utils.clone(defaultOptions[key]);
28602 }
28603 }
28604
28605 normalized = options;
28606 } else {
28607 normalized = Utils.clone(defaultOptions);
28608 }
28609
28610 if (normalized.strictMode === true) {
28611 normalized.forceAdditional = true;
28612 normalized.forceItems = true;
28613 normalized.forceMaxLength = true;
28614 normalized.forceProperties = true;
28615 normalized.noExtraKeywords = true;
28616 normalized.noTypeless = true;
28617 normalized.noEmptyStrings = true;
28618 normalized.noEmptyArrays = true;
28619 }
28620
28621 return normalized;
28622}
28623
28624/**
28625 * @class
28626 *
28627 * @param {*} [options]
28628 */
28629function ZSchema(options) {
28630 this.cache = {};
28631 this.referenceCache = [];
28632 this.validateOptions = {};
28633
28634 this.options = normalizeOptions(options);
28635
28636 // Disable strict validation for the built-in schemas
28637 var metaschemaOptions = normalizeOptions({ });
28638
28639 this.setRemoteReference("http://json-schema.org/draft-04/schema", Draft4Schema, metaschemaOptions);
28640 this.setRemoteReference("http://json-schema.org/draft-04/hyper-schema", Draft4HyperSchema, metaschemaOptions);
28641}
28642
28643/**
28644 * instance methods
28645 *
28646 * @param {*} schema
28647 *
28648 * @returns {boolean}
28649 */
28650ZSchema.prototype.compileSchema = function (schema) {
28651 var report = new Report(this.options);
28652
28653 schema = SchemaCache.getSchema.call(this, report, schema);
28654
28655 SchemaCompilation.compileSchema.call(this, report, schema);
28656
28657 this.lastReport = report;
28658 return report.isValid();
28659};
28660
28661/**
28662 *
28663 * @param {*} schema
28664 *
28665 * @returns {boolean}
28666 */
28667ZSchema.prototype.validateSchema = function (schema) {
28668 if (Array.isArray(schema) && schema.length === 0) {
28669 throw new Error(".validateSchema was called with an empty array");
28670 }
28671
28672 var report = new Report(this.options);
28673
28674 schema = SchemaCache.getSchema.call(this, report, schema);
28675
28676 var compiled = SchemaCompilation.compileSchema.call(this, report, schema);
28677 if (compiled) { SchemaValidation.validateSchema.call(this, report, schema); }
28678
28679 this.lastReport = report;
28680 return report.isValid();
28681};
28682
28683/**
28684 *
28685 * @param {*} json
28686 * @param {*} schema
28687 * @param {*} [options]
28688 * @param {function(*, *)} [callback]
28689 *
28690 * @returns {boolean}
28691 */
28692ZSchema.prototype.validate = function (json, schema, options, callback) {
28693
28694 if (Utils.whatIs(options) === "function") {
28695 callback = options;
28696 options = {};
28697 }
28698 if (!options) { options = {}; }
28699
28700 this.validateOptions = options;
28701
28702 var whatIs = Utils.whatIs(schema);
28703 if (whatIs !== "string" && whatIs !== "object") {
28704 var e = new Error("Invalid .validate call - schema must be an string or object but " + whatIs + " was passed!");
28705 if (callback) {
28706 process.nextTick(function () {
28707 callback(e, false);
28708 });
28709 return;
28710 }
28711 throw e;
28712 }
28713
28714 var foundError = false;
28715 var report = new Report(this.options);
28716 report.json = json;
28717
28718 if (typeof schema === "string") {
28719 var schemaName = schema;
28720 schema = SchemaCache.getSchema.call(this, report, schemaName);
28721 if (!schema) {
28722 throw new Error("Schema with id '" + schemaName + "' wasn't found in the validator cache!");
28723 }
28724 } else {
28725 schema = SchemaCache.getSchema.call(this, report, schema);
28726 }
28727
28728 var compiled = false;
28729 if (!foundError) {
28730 compiled = SchemaCompilation.compileSchema.call(this, report, schema);
28731 }
28732 if (!compiled) {
28733 this.lastReport = report;
28734 foundError = true;
28735 }
28736
28737 var validated = false;
28738 if (!foundError) {
28739 validated = SchemaValidation.validateSchema.call(this, report, schema);
28740 }
28741 if (!validated) {
28742 this.lastReport = report;
28743 foundError = true;
28744 }
28745
28746 if (options.schemaPath) {
28747 report.rootSchema = schema;
28748 schema = get(schema, options.schemaPath);
28749 if (!schema) {
28750 throw new Error("Schema path '" + options.schemaPath + "' wasn't found in the schema!");
28751 }
28752 }
28753
28754 if (!foundError) {
28755 JsonValidation.validate.call(this, report, schema, json);
28756 }
28757
28758 if (callback) {
28759 report.processAsyncTasks(this.options.asyncTimeout, callback);
28760 return;
28761 } else if (report.asyncTasks.length > 0) {
28762 throw new Error("This validation has async tasks and cannot be done in sync mode, please provide callback argument.");
28763 }
28764
28765 // assign lastReport so errors are retrievable in sync mode
28766 this.lastReport = report;
28767 return report.isValid();
28768};
28769ZSchema.prototype.getLastError = function () {
28770 if (this.lastReport.errors.length === 0) {
28771 return null;
28772 }
28773 var e = new Error();
28774 e.name = "z-schema validation error";
28775 e.message = this.lastReport.commonErrorMessage;
28776 e.details = this.lastReport.errors;
28777 return e;
28778};
28779ZSchema.prototype.getLastErrors = function () {
28780 return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : undefined;
28781};
28782ZSchema.prototype.getMissingReferences = function (arr) {
28783 arr = arr || this.lastReport.errors;
28784 var res = [],
28785 idx = arr.length;
28786 while (idx--) {
28787 var error = arr[idx];
28788 if (error.code === "UNRESOLVABLE_REFERENCE") {
28789 var reference = error.params[0];
28790 if (res.indexOf(reference) === -1) {
28791 res.push(reference);
28792 }
28793 }
28794 if (error.inner) {
28795 res = res.concat(this.getMissingReferences(error.inner));
28796 }
28797 }
28798 return res;
28799};
28800ZSchema.prototype.getMissingRemoteReferences = function () {
28801 var missingReferences = this.getMissingReferences(),
28802 missingRemoteReferences = [],
28803 idx = missingReferences.length;
28804 while (idx--) {
28805 var remoteReference = SchemaCache.getRemotePath(missingReferences[idx]);
28806 if (remoteReference && missingRemoteReferences.indexOf(remoteReference) === -1) {
28807 missingRemoteReferences.push(remoteReference);
28808 }
28809 }
28810 return missingRemoteReferences;
28811};
28812ZSchema.prototype.setRemoteReference = function (uri, schema, validationOptions) {
28813 if (typeof schema === "string") {
28814 schema = JSON.parse(schema);
28815 } else {
28816 schema = Utils.cloneDeep(schema);
28817 }
28818
28819 if (validationOptions) {
28820 schema.__$validationOptions = normalizeOptions(validationOptions);
28821 }
28822
28823 SchemaCache.cacheSchemaByUri.call(this, uri, schema);
28824};
28825ZSchema.prototype.getResolvedSchema = function (schema) {
28826 var report = new Report(this.options);
28827 schema = SchemaCache.getSchema.call(this, report, schema);
28828
28829 // clone before making any modifications
28830 schema = Utils.cloneDeep(schema);
28831
28832 var visited = [];
28833
28834 // clean-up the schema and resolve references
28835 var cleanup = function (schema) {
28836 var key,
28837 typeOf = Utils.whatIs(schema);
28838 if (typeOf !== "object" && typeOf !== "array") {
28839 return;
28840 }
28841
28842 if (schema.___$visited) {
28843 return;
28844 }
28845
28846 schema.___$visited = true;
28847 visited.push(schema);
28848
28849 if (schema.$ref && schema.__$refResolved) {
28850 var from = schema.__$refResolved;
28851 var to = schema;
28852 delete schema.$ref;
28853 delete schema.__$refResolved;
28854 for (key in from) {
28855 if (from.hasOwnProperty(key)) {
28856 to[key] = from[key];
28857 }
28858 }
28859 }
28860 for (key in schema) {
28861 if (schema.hasOwnProperty(key)) {
28862 if (key.indexOf("__$") === 0) {
28863 delete schema[key];
28864 } else {
28865 cleanup(schema[key]);
28866 }
28867 }
28868 }
28869 };
28870
28871 cleanup(schema);
28872 visited.forEach(function (s) {
28873 delete s.___$visited;
28874 });
28875
28876 this.lastReport = report;
28877 if (report.isValid()) {
28878 return schema;
28879 } else {
28880 throw this.getLastError();
28881 }
28882};
28883
28884/**
28885 *
28886 * @param {*} schemaReader
28887 *
28888 * @returns {void}
28889 */
28890ZSchema.prototype.setSchemaReader = function (schemaReader) {
28891 return ZSchema.setSchemaReader(schemaReader);
28892};
28893
28894ZSchema.prototype.getSchemaReader = function () {
28895 return ZSchema.schemaReader;
28896};
28897
28898ZSchema.schemaReader = undefined;
28899/*
28900 static methods
28901*/
28902ZSchema.setSchemaReader = function (schemaReader) {
28903 ZSchema.schemaReader = schemaReader;
28904};
28905ZSchema.registerFormat = function (formatName, validatorFunction) {
28906 FormatValidators[formatName] = validatorFunction;
28907};
28908ZSchema.unregisterFormat = function (formatName) {
28909 delete FormatValidators[formatName];
28910};
28911ZSchema.getRegisteredFormats = function () {
28912 return Object.keys(FormatValidators);
28913};
28914ZSchema.getDefaultOptions = function () {
28915 return Utils.cloneDeep(defaultOptions);
28916};
28917
28918ZSchema.schemaSymbol = Utils.schemaSymbol;
28919
28920ZSchema.jsonSymbol = Utils.jsonSymbol;
28921
28922module.exports = ZSchema;
28923
28924}).call(this,require('_process'))
28925
28926},{"./FormatValidators":233,"./JsonValidation":234,"./Polyfills":235,"./Report":236,"./SchemaCache":237,"./SchemaCompilation":238,"./SchemaValidation":239,"./Utils":240,"./schemas/hyper-schema.json":242,"./schemas/schema.json":243,"_process":125,"lodash.get":120}],242:[function(require,module,exports){
28927module.exports={
28928 "$schema": "http://json-schema.org/draft-04/hyper-schema#",
28929 "id": "http://json-schema.org/draft-04/hyper-schema#",
28930 "title": "JSON Hyper-Schema",
28931 "allOf": [
28932 {
28933 "$ref": "http://json-schema.org/draft-04/schema#"
28934 }
28935 ],
28936 "properties": {
28937 "additionalItems": {
28938 "anyOf": [
28939 {
28940 "type": "boolean"
28941 },
28942 {
28943 "$ref": "#"
28944 }
28945 ]
28946 },
28947 "additionalProperties": {
28948 "anyOf": [
28949 {
28950 "type": "boolean"
28951 },
28952 {
28953 "$ref": "#"
28954 }
28955 ]
28956 },
28957 "dependencies": {
28958 "additionalProperties": {
28959 "anyOf": [
28960 {
28961 "$ref": "#"
28962 },
28963 {
28964 "type": "array"
28965 }
28966 ]
28967 }
28968 },
28969 "items": {
28970 "anyOf": [
28971 {
28972 "$ref": "#"
28973 },
28974 {
28975 "$ref": "#/definitions/schemaArray"
28976 }
28977 ]
28978 },
28979 "definitions": {
28980 "additionalProperties": {
28981 "$ref": "#"
28982 }
28983 },
28984 "patternProperties": {
28985 "additionalProperties": {
28986 "$ref": "#"
28987 }
28988 },
28989 "properties": {
28990 "additionalProperties": {
28991 "$ref": "#"
28992 }
28993 },
28994 "allOf": {
28995 "$ref": "#/definitions/schemaArray"
28996 },
28997 "anyOf": {
28998 "$ref": "#/definitions/schemaArray"
28999 },
29000 "oneOf": {
29001 "$ref": "#/definitions/schemaArray"
29002 },
29003 "not": {
29004 "$ref": "#"
29005 },
29006
29007 "links": {
29008 "type": "array",
29009 "items": {
29010 "$ref": "#/definitions/linkDescription"
29011 }
29012 },
29013 "fragmentResolution": {
29014 "type": "string"
29015 },
29016 "media": {
29017 "type": "object",
29018 "properties": {
29019 "type": {
29020 "description": "A media type, as described in RFC 2046",
29021 "type": "string"
29022 },
29023 "binaryEncoding": {
29024 "description": "A content encoding scheme, as described in RFC 2045",
29025 "type": "string"
29026 }
29027 }
29028 },
29029 "pathStart": {
29030 "description": "Instances' URIs must start with this value for this schema to apply to them",
29031 "type": "string",
29032 "format": "uri"
29033 }
29034 },
29035 "definitions": {
29036 "schemaArray": {
29037 "type": "array",
29038 "items": {
29039 "$ref": "#"
29040 }
29041 },
29042 "linkDescription": {
29043 "title": "Link Description Object",
29044 "type": "object",
29045 "required": [ "href", "rel" ],
29046 "properties": {
29047 "href": {
29048 "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing",
29049 "type": "string"
29050 },
29051 "rel": {
29052 "description": "relation to the target resource of the link",
29053 "type": "string"
29054 },
29055 "title": {
29056 "description": "a title for the link",
29057 "type": "string"
29058 },
29059 "targetSchema": {
29060 "description": "JSON Schema describing the link target",
29061 "$ref": "#"
29062 },
29063 "mediaType": {
29064 "description": "media type (as defined by RFC 2046) describing the link target",
29065 "type": "string"
29066 },
29067 "method": {
29068 "description": "method for requesting the target of the link (e.g. for HTTP this might be \"GET\" or \"DELETE\")",
29069 "type": "string"
29070 },
29071 "encType": {
29072 "description": "The media type in which to submit data along with the request",
29073 "type": "string",
29074 "default": "application/json"
29075 },
29076 "schema": {
29077 "description": "Schema describing the data to submit along with the request",
29078 "$ref": "#"
29079 }
29080 }
29081 }
29082 }
29083}
29084
29085
29086},{}],243:[function(require,module,exports){
29087module.exports={
29088 "id": "http://json-schema.org/draft-04/schema#",
29089 "$schema": "http://json-schema.org/draft-04/schema#",
29090 "description": "Core schema meta-schema",
29091 "definitions": {
29092 "schemaArray": {
29093 "type": "array",
29094 "minItems": 1,
29095 "items": { "$ref": "#" }
29096 },
29097 "positiveInteger": {
29098 "type": "integer",
29099 "minimum": 0
29100 },
29101 "positiveIntegerDefault0": {
29102 "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
29103 },
29104 "simpleTypes": {
29105 "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
29106 },
29107 "stringArray": {
29108 "type": "array",
29109 "items": { "type": "string" },
29110 "minItems": 1,
29111 "uniqueItems": true
29112 }
29113 },
29114 "type": "object",
29115 "properties": {
29116 "id": {
29117 "type": "string",
29118 "format": "uri"
29119 },
29120 "$schema": {
29121 "type": "string",
29122 "format": "uri"
29123 },
29124 "title": {
29125 "type": "string"
29126 },
29127 "description": {
29128 "type": "string"
29129 },
29130 "default": {},
29131 "multipleOf": {
29132 "type": "number",
29133 "minimum": 0,
29134 "exclusiveMinimum": true
29135 },
29136 "maximum": {
29137 "type": "number"
29138 },
29139 "exclusiveMaximum": {
29140 "type": "boolean",
29141 "default": false
29142 },
29143 "minimum": {
29144 "type": "number"
29145 },
29146 "exclusiveMinimum": {
29147 "type": "boolean",
29148 "default": false
29149 },
29150 "maxLength": { "$ref": "#/definitions/positiveInteger" },
29151 "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
29152 "pattern": {
29153 "type": "string",
29154 "format": "regex"
29155 },
29156 "additionalItems": {
29157 "anyOf": [
29158 { "type": "boolean" },
29159 { "$ref": "#" }
29160 ],
29161 "default": {}
29162 },
29163 "items": {
29164 "anyOf": [
29165 { "$ref": "#" },
29166 { "$ref": "#/definitions/schemaArray" }
29167 ],
29168 "default": {}
29169 },
29170 "maxItems": { "$ref": "#/definitions/positiveInteger" },
29171 "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
29172 "uniqueItems": {
29173 "type": "boolean",
29174 "default": false
29175 },
29176 "maxProperties": { "$ref": "#/definitions/positiveInteger" },
29177 "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
29178 "required": { "$ref": "#/definitions/stringArray" },
29179 "additionalProperties": {
29180 "anyOf": [
29181 { "type": "boolean" },
29182 { "$ref": "#" }
29183 ],
29184 "default": {}
29185 },
29186 "definitions": {
29187 "type": "object",
29188 "additionalProperties": { "$ref": "#" },
29189 "default": {}
29190 },
29191 "properties": {
29192 "type": "object",
29193 "additionalProperties": { "$ref": "#" },
29194 "default": {}
29195 },
29196 "patternProperties": {
29197 "type": "object",
29198 "additionalProperties": { "$ref": "#" },
29199 "default": {}
29200 },
29201 "dependencies": {
29202 "type": "object",
29203 "additionalProperties": {
29204 "anyOf": [
29205 { "$ref": "#" },
29206 { "$ref": "#/definitions/stringArray" }
29207 ]
29208 }
29209 },
29210 "enum": {
29211 "type": "array",
29212 "minItems": 1,
29213 "uniqueItems": true
29214 },
29215 "type": {
29216 "anyOf": [
29217 { "$ref": "#/definitions/simpleTypes" },
29218 {
29219 "type": "array",
29220 "items": { "$ref": "#/definitions/simpleTypes" },
29221 "minItems": 1,
29222 "uniqueItems": true
29223 }
29224 ]
29225 },
29226 "format": { "type": "string" },
29227 "allOf": { "$ref": "#/definitions/schemaArray" },
29228 "anyOf": { "$ref": "#/definitions/schemaArray" },
29229 "oneOf": { "$ref": "#/definitions/schemaArray" },
29230 "not": { "$ref": "#" }
29231 },
29232 "dependencies": {
29233 "exclusiveMaximum": [ "maximum" ],
29234 "exclusiveMinimum": [ "minimum" ]
29235 },
29236 "default": {}
29237}
29238
29239},{}]},{},[1])(1)
29240});
29241//# sourceMappingURL=swagger-parser.js.map