1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
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 |
|
12 | var 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 |
|
22 | module.exports = SwaggerParser;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | function SwaggerParser () {
|
32 | $RefParser.apply(this, arguments);
|
33 | }
|
34 |
|
35 | util.inherits(SwaggerParser, $RefParser);
|
36 | SwaggerParser.YAML = $RefParser.YAML;
|
37 | SwaggerParser.parse = $RefParser.parse;
|
38 | SwaggerParser.resolve = $RefParser.resolve;
|
39 | SwaggerParser.bundle = $RefParser.bundle;
|
40 | SwaggerParser.dereference = $RefParser.dereference;
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | Object.defineProperty(SwaggerParser.prototype, "api", {
|
46 | configurable: true,
|
47 | enumerable: true,
|
48 | get: function () {
|
49 | return this.schema;
|
50 | }
|
51 | });
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | SwaggerParser.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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | SwaggerParser.validate = function (path, api, options, callback) {
|
128 | var Class = this;
|
129 | var instance = new Class();
|
130 | return instance.validate.apply(instance, arguments);
|
131 | };
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 | SwaggerParser.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 |
|
149 |
|
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 |
|
156 | args.options.dereference.circular = circular$RefOption;
|
157 |
|
158 | if (args.options.validate.schema) {
|
159 |
|
160 |
|
161 | validateSchema(me.api);
|
162 |
|
163 | if (me.$refs.circular) {
|
164 | if (circular$RefOption === true) {
|
165 |
|
166 |
|
167 | dereference(me, args.options);
|
168 | }
|
169 | else if (circular$RefOption === false) {
|
170 |
|
171 | throw ono.reference("The API contains circular references");
|
172 | }
|
173 | }
|
174 | }
|
175 |
|
176 | if (args.options.validate.spec) {
|
177 |
|
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 |
|
190 |
|
191 |
|
192 |
|
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 |
|
198 | var $RefParserOptions = require("json-schema-ref-parser/lib/options"),
|
199 | schemaValidator = require("./validators/schema"),
|
200 | specValidator = require("./validators/spec"),
|
201 | util = require("util");
|
202 |
|
203 | module.exports = ParserOptions;
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | function ParserOptions (options) {
|
213 | $RefParserOptions.call(this, ParserOptions.defaults);
|
214 | $RefParserOptions.apply(this, arguments);
|
215 | }
|
216 |
|
217 | ParserOptions.defaults = {
|
218 | |
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 | validate: {
|
225 | schema: schemaValidator,
|
226 | spec: specValidator,
|
227 | },
|
228 | };
|
229 |
|
230 | util.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 |
|
235 | var util = require("util");
|
236 |
|
237 | exports.format = util.format;
|
238 | exports.inherits = util.inherits;
|
239 |
|
240 |
|
241 |
|
242 |
|
243 | exports.swaggerParamRegExp = /\{([^/}]+)}/g;
|
244 |
|
245 | },{"util":152}],4:[function(require,module,exports){
|
246 | "use strict";
|
247 |
|
248 | var util = require("../util"),
|
249 | ono = require("ono"),
|
250 | ZSchema = require("z-schema");
|
251 |
|
252 | module.exports = validateSchema;
|
253 |
|
254 | initializeZSchema();
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 | function validateSchema (api) {
|
262 |
|
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 |
|
278 |
|
279 | function initializeZSchema () {
|
280 | ZSchema = new ZSchema({
|
281 | breakOnFirstError: true,
|
282 | noExtraKeywords: true,
|
283 | ignoreUnknownFormats: false,
|
284 | reportPathAsArray: true
|
285 | });
|
286 | }
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 | function 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 |
|
311 | var 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 |
|
317 | module.exports = validateSpec;
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | function validateSpec (api) {
|
325 | if (api.openapi) {
|
326 |
|
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 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 | function 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 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 | function validateParameters (api, path, pathId, operation, operationId) {
|
393 | var pathParams = path.parameters || [];
|
394 | var operationParams = operation.parameters || [];
|
395 |
|
396 |
|
397 | try {
|
398 | checkForDuplicates(pathParams);
|
399 | }
|
400 | catch (e) {
|
401 | throw ono.syntax(e, "Validation failed. %s has duplicate parameters", pathId);
|
402 | }
|
403 |
|
404 |
|
405 | try {
|
406 | checkForDuplicates(operationParams);
|
407 | }
|
408 | catch (e) {
|
409 | throw ono.syntax(e, "Validation failed. %s has duplicate parameters", operationId);
|
410 | }
|
411 |
|
412 |
|
413 |
|
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 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 | function 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 |
|
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 |
|
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 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 | function validatePathParameters (params, pathId, operationId) {
|
463 |
|
464 | var placeholders = pathId.match(util.swaggerParamRegExp) || [];
|
465 |
|
466 |
|
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 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 | function 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 |
|
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 |
|
558 |
|
559 |
|
560 |
|
561 | function 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 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 | function 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 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 | function 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 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 | function validateRequiredPropertiesExist (schema, schemaId) {
|
629 | |
630 |
|
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 |
|
662 | exports.byteLength = byteLength
|
663 | exports.toByteArray = toByteArray
|
664 | exports.fromByteArray = fromByteArray
|
665 |
|
666 | var lookup = []
|
667 | var revLookup = []
|
668 | var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
669 |
|
670 | var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
671 | for (var i = 0, len = code.length; i < len; ++i) {
|
672 | lookup[i] = code[i]
|
673 | revLookup[code.charCodeAt(i)] = i
|
674 | }
|
675 |
|
676 |
|
677 |
|
678 | revLookup['-'.charCodeAt(0)] = 62
|
679 | revLookup['_'.charCodeAt(0)] = 63
|
680 |
|
681 | function 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 |
|
689 |
|
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 |
|
701 | function 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 |
|
708 | function _byteLength (b64, validLen, placeHoldersLen) {
|
709 | return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
710 | }
|
711 |
|
712 | function 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 |
|
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 |
|
757 | function tripletToBase64 (num) {
|
758 | return lookup[num >> 18 & 0x3F] +
|
759 | lookup[num >> 12 & 0x3F] +
|
760 | lookup[num >> 6 & 0x3F] +
|
761 | lookup[num & 0x3F]
|
762 | }
|
763 |
|
764 | function 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 |
|
777 | function fromByteArray (uint8) {
|
778 | var tmp
|
779 | var len = uint8.length
|
780 | var extraBytes = len % 3
|
781 | var parts = []
|
782 | var maxChunkLength = 16383
|
783 |
|
784 |
|
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 |
|
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 |
|
817 | ;(function(root) {
|
818 |
|
819 |
|
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 |
|
835 |
|
836 |
|
837 |
|
838 | var punycode,
|
839 |
|
840 |
|
841 | maxInt = 2147483647,
|
842 |
|
843 |
|
844 | base = 36,
|
845 | tMin = 1,
|
846 | tMax = 26,
|
847 | skew = 38,
|
848 | damp = 700,
|
849 | initialBias = 72,
|
850 | initialN = 128,
|
851 | delimiter = '-',
|
852 |
|
853 |
|
854 | regexPunycode = /^xn--/,
|
855 | regexNonASCII = /[^\x20-\x7E]/,
|
856 | regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g,
|
857 |
|
858 |
|
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 |
|
866 | baseMinusTMin = base - tMin,
|
867 | floor = Math.floor,
|
868 | stringFromCharCode = String.fromCharCode,
|
869 |
|
870 |
|
871 | key;
|
872 |
|
873 |
|
874 |
|
875 | |
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 | function error(type) {
|
882 | throw new RangeError(errors[type]);
|
883 | }
|
884 |
|
885 | |
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
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 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 | function mapDomain(string, fn) {
|
913 | var parts = string.split('@');
|
914 | var result = '';
|
915 | if (parts.length > 1) {
|
916 |
|
917 |
|
918 | result = parts[0] + '@';
|
919 | string = parts[1];
|
920 | }
|
921 |
|
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 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
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 |
|
951 | extra = string.charCodeAt(counter++);
|
952 | if ((extra & 0xFC00) == 0xDC00) {
|
953 | output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
954 | } else {
|
955 |
|
956 |
|
957 | output.push(value);
|
958 | counter--;
|
959 | }
|
960 | } else {
|
961 | output.push(value);
|
962 | }
|
963 | }
|
964 | return output;
|
965 | }
|
966 |
|
967 | |
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
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 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
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 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 | function digitToBasic(digit, flag) {
|
1022 |
|
1023 |
|
1024 | return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
1025 | }
|
1026 |
|
1027 | |
1028 |
|
1029 |
|
1030 |
|
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 (; 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 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 | function decode(input) {
|
1050 |
|
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 |
|
1066 | baseMinusT;
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 | basic = input.lastIndexOf(delimiter);
|
1073 | if (basic < 0) {
|
1074 | basic = 0;
|
1075 | }
|
1076 |
|
1077 | for (j = 0; j < basic; ++j) {
|
1078 |
|
1079 | if (input.charCodeAt(j) >= 0x80) {
|
1080 | error('not-basic');
|
1081 | }
|
1082 | output.push(input.charCodeAt(j));
|
1083 | }
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 | for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 | for (oldi = i, w = 1, k = base; ; 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 |
|
1127 |
|
1128 | if (floor(i / out) > maxInt - n) {
|
1129 | error('overflow');
|
1130 | }
|
1131 |
|
1132 | n += floor(i / out);
|
1133 | i %= out;
|
1134 |
|
1135 |
|
1136 | output.splice(i++, 0, n);
|
1137 |
|
1138 | }
|
1139 |
|
1140 | return ucs2encode(output);
|
1141 | }
|
1142 |
|
1143 | |
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
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 |
|
1164 | inputLength,
|
1165 |
|
1166 | handledCPCountPlusOne,
|
1167 | baseMinusT,
|
1168 | qMinusT;
|
1169 |
|
1170 |
|
1171 | input = ucs2decode(input);
|
1172 |
|
1173 |
|
1174 | inputLength = input.length;
|
1175 |
|
1176 |
|
1177 | n = initialN;
|
1178 | delta = 0;
|
1179 | bias = initialBias;
|
1180 |
|
1181 |
|
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 |
|
1192 |
|
1193 |
|
1194 |
|
1195 | if (basicLength) {
|
1196 | output.push(delimiter);
|
1197 | }
|
1198 |
|
1199 |
|
1200 | while (handledCPCount < inputLength) {
|
1201 |
|
1202 |
|
1203 |
|
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 |
|
1212 |
|
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 |
|
1230 | for (q = delta, k = base; ; 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 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
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 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
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 |
|
1298 | punycode = {
|
1299 | |
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 | 'version': '1.4.1',
|
1305 | |
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
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 |
|
1323 |
|
1324 |
|
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 |
|
1336 | freeModule.exports = punycode;
|
1337 | } else {
|
1338 |
|
1339 | for (key in punycode) {
|
1340 | punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
1341 | }
|
1342 | }
|
1343 | } else {
|
1344 |
|
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 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 | 'use strict'
|
1362 |
|
1363 | var base64 = require('base64-js')
|
1364 | var ieee754 = require('ieee754')
|
1365 |
|
1366 | exports.Buffer = Buffer
|
1367 | exports.SlowBuffer = SlowBuffer
|
1368 | exports.INSPECT_MAX_BYTES = 50
|
1369 |
|
1370 | var K_MAX_LENGTH = 0x7fffffff
|
1371 | exports.kMaxLength = K_MAX_LENGTH
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 | Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
|
1388 |
|
1389 | if (!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 |
|
1397 | function typedArraySupport () {
|
1398 |
|
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 |
|
1408 | Object.defineProperty(Buffer.prototype, 'parent', {
|
1409 | enumerable: true,
|
1410 | get: function () {
|
1411 | if (!Buffer.isBuffer(this)) return undefined
|
1412 | return this.buffer
|
1413 | }
|
1414 | })
|
1415 |
|
1416 | Object.defineProperty(Buffer.prototype, 'offset', {
|
1417 | enumerable: true,
|
1418 | get: function () {
|
1419 | if (!Buffer.isBuffer(this)) return undefined
|
1420 | return this.byteOffset
|
1421 | }
|
1422 | })
|
1423 |
|
1424 | function createBuffer (length) {
|
1425 | if (length > K_MAX_LENGTH) {
|
1426 | throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
1427 | }
|
1428 |
|
1429 | var buf = new Uint8Array(length)
|
1430 | buf.__proto__ = Buffer.prototype
|
1431 | return buf
|
1432 | }
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 | function Buffer (arg, encodingOrOffset, length) {
|
1445 |
|
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 |
|
1458 | if (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 |
|
1468 | Buffer.poolSize = 8192
|
1469 |
|
1470 | function 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 |
|
1520 |
|
1521 |
|
1522 |
|
1523 |
|
1524 |
|
1525 |
|
1526 | Buffer.from = function (value, encodingOrOffset, length) {
|
1527 | return from(value, encodingOrOffset, length)
|
1528 | }
|
1529 |
|
1530 |
|
1531 |
|
1532 | Buffer.prototype.__proto__ = Uint8Array.prototype
|
1533 | Buffer.__proto__ = Uint8Array
|
1534 |
|
1535 | function 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 |
|
1543 | function alloc (size, fill, encoding) {
|
1544 | assertSize(size)
|
1545 | if (size <= 0) {
|
1546 | return createBuffer(size)
|
1547 | }
|
1548 | if (fill !== undefined) {
|
1549 |
|
1550 |
|
1551 |
|
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 |
|
1561 |
|
1562 |
|
1563 | Buffer.alloc = function (size, fill, encoding) {
|
1564 | return alloc(size, fill, encoding)
|
1565 | }
|
1566 |
|
1567 | function allocUnsafe (size) {
|
1568 | assertSize(size)
|
1569 | return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
1570 | }
|
1571 |
|
1572 |
|
1573 |
|
1574 |
|
1575 | Buffer.allocUnsafe = function (size) {
|
1576 | return allocUnsafe(size)
|
1577 | }
|
1578 |
|
1579 |
|
1580 |
|
1581 | Buffer.allocUnsafeSlow = function (size) {
|
1582 | return allocUnsafe(size)
|
1583 | }
|
1584 |
|
1585 | function 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 |
|
1601 |
|
1602 |
|
1603 | buf = buf.slice(0, actual)
|
1604 | }
|
1605 |
|
1606 | return buf
|
1607 | }
|
1608 |
|
1609 | function 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 |
|
1618 | function 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 |
|
1637 | buf.__proto__ = Buffer.prototype
|
1638 | return buf
|
1639 | }
|
1640 |
|
1641 | function 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 |
|
1666 | function checked (length) {
|
1667 |
|
1668 |
|
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 |
|
1676 | function SlowBuffer (length) {
|
1677 | if (+length != length) {
|
1678 | length = 0
|
1679 | }
|
1680 | return Buffer.alloc(+length)
|
1681 | }
|
1682 |
|
1683 | Buffer.isBuffer = function isBuffer (b) {
|
1684 | return b != null && b._isBuffer === true &&
|
1685 | b !== Buffer.prototype
|
1686 | }
|
1687 |
|
1688 | Buffer.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 |
|
1715 | Buffer.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 |
|
1734 | Buffer.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 |
|
1767 | function 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 |
|
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
|
1808 | }
|
1809 | encoding = ('' + encoding).toLowerCase()
|
1810 | loweredCase = true
|
1811 | }
|
1812 | }
|
1813 | }
|
1814 | Buffer.byteLength = byteLength
|
1815 |
|
1816 | function slowToString (encoding, start, end) {
|
1817 | var loweredCase = false
|
1818 |
|
1819 |
|
1820 |
|
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 | if (start === undefined || start < 0) {
|
1827 | start = 0
|
1828 | }
|
1829 |
|
1830 |
|
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 |
|
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 |
|
1887 |
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 | Buffer.prototype._isBuffer = true
|
1893 |
|
1894 | function swap (b, n, m) {
|
1895 | var i = b[n]
|
1896 | b[n] = b[m]
|
1897 | b[m] = i
|
1898 | }
|
1899 |
|
1900 | Buffer.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 |
|
1911 | Buffer.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 |
|
1923 | Buffer.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 |
|
1937 | Buffer.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 |
|
1944 | Buffer.prototype.toLocaleString = Buffer.prototype.toString
|
1945 |
|
1946 | Buffer.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 |
|
1952 | Buffer.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 |
|
1960 | Buffer.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 |
|
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 |
|
2033 |
|
2034 | function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
2035 |
|
2036 | if (buffer.length === 0) return -1
|
2037 |
|
2038 |
|
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
|
2048 | if (numberIsNaN(byteOffset)) {
|
2049 |
|
2050 | byteOffset = dir ? 0 : (buffer.length - 1)
|
2051 | }
|
2052 |
|
2053 |
|
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 |
|
2064 | if (typeof val === 'string') {
|
2065 | val = Buffer.from(val, encoding)
|
2066 | }
|
2067 |
|
2068 |
|
2069 | if (Buffer.isBuffer(val)) {
|
2070 |
|
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
|
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 |
|
2090 | function 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 |
|
2146 | Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
2147 | return this.indexOf(val, byteOffset, encoding) !== -1
|
2148 | }
|
2149 |
|
2150 | Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
2151 | return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
2152 | }
|
2153 |
|
2154 | Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
2155 | return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
2156 | }
|
2157 |
|
2158 | function 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 |
|
2183 | function utf8Write (buf, string, offset, length) {
|
2184 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
2185 | }
|
2186 |
|
2187 | function asciiWrite (buf, string, offset, length) {
|
2188 | return blitBuffer(asciiToBytes(string), buf, offset, length)
|
2189 | }
|
2190 |
|
2191 | function latin1Write (buf, string, offset, length) {
|
2192 | return asciiWrite(buf, string, offset, length)
|
2193 | }
|
2194 |
|
2195 | function base64Write (buf, string, offset, length) {
|
2196 | return blitBuffer(base64ToBytes(string), buf, offset, length)
|
2197 | }
|
2198 |
|
2199 | function ucs2Write (buf, string, offset, length) {
|
2200 | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
2201 | }
|
2202 |
|
2203 | Buffer.prototype.write = function write (string, offset, length, encoding) {
|
2204 |
|
2205 | if (offset === undefined) {
|
2206 | encoding = 'utf8'
|
2207 | length = this.length
|
2208 | offset = 0
|
2209 |
|
2210 | } else if (length === undefined && typeof offset === 'string') {
|
2211 | encoding = offset
|
2212 | length = this.length
|
2213 | offset = 0
|
2214 |
|
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 |
|
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 |
|
2274 | Buffer.prototype.toJSON = function toJSON () {
|
2275 | return {
|
2276 | type: 'Buffer',
|
2277 | data: Array.prototype.slice.call(this._arr || this, 0)
|
2278 | }
|
2279 | }
|
2280 |
|
2281 | function 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 |
|
2289 | function 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 |
|
2345 |
|
2346 | codePoint = 0xFFFD
|
2347 | bytesPerSequence = 1
|
2348 | } else if (codePoint > 0xFFFF) {
|
2349 |
|
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 |
|
2363 |
|
2364 |
|
2365 | var MAX_ARGUMENTS_LENGTH = 0x1000
|
2366 |
|
2367 | function decodeCodePointsArray (codePoints) {
|
2368 | var len = codePoints.length
|
2369 | if (len <= MAX_ARGUMENTS_LENGTH) {
|
2370 | return String.fromCharCode.apply(String, codePoints)
|
2371 | }
|
2372 |
|
2373 |
|
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 |
|
2385 | function 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 |
|
2395 | function 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 |
|
2405 | function 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 |
|
2418 | function 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 |
|
2427 | Buffer.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 |
|
2450 | newBuf.__proto__ = Buffer.prototype
|
2451 | return newBuf
|
2452 | }
|
2453 |
|
2454 |
|
2455 |
|
2456 |
|
2457 | function 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 |
|
2462 | Buffer.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 |
|
2477 | Buffer.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 |
|
2493 | Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
2494 | offset = offset >>> 0
|
2495 | if (!noAssert) checkOffset(offset, 1, this.length)
|
2496 | return this[offset]
|
2497 | }
|
2498 |
|
2499 | Buffer.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 |
|
2505 | Buffer.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 |
|
2511 | Buffer.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 |
|
2521 | Buffer.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 |
|
2531 | Buffer.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 |
|
2549 | Buffer.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 |
|
2567 | Buffer.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 |
|
2574 | Buffer.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 |
|
2581 | Buffer.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 |
|
2588 | Buffer.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 |
|
2598 | Buffer.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 |
|
2608 | Buffer.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 |
|
2614 | Buffer.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 |
|
2620 | Buffer.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 |
|
2626 | Buffer.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 |
|
2632 | function 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 |
|
2638 | Buffer.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 |
|
2657 | Buffer.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 |
|
2676 | Buffer.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 |
|
2684 | Buffer.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 |
|
2693 | Buffer.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 |
|
2702 | Buffer.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 |
|
2713 | Buffer.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 |
|
2724 | Buffer.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 |
|
2747 | Buffer.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 |
|
2770 | Buffer.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 |
|
2779 | Buffer.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 |
|
2788 | Buffer.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 |
|
2797 | Buffer.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 |
|
2808 | Buffer.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 |
|
2820 | function 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 |
|
2825 | function 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 |
|
2835 | Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
2836 | return writeFloat(this, value, offset, true, noAssert)
|
2837 | }
|
2838 |
|
2839 | Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
2840 | return writeFloat(this, value, offset, false, noAssert)
|
2841 | }
|
2842 |
|
2843 | function 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 |
|
2853 | Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
2854 | return writeDouble(this, value, offset, true, noAssert)
|
2855 | }
|
2856 |
|
2857 | Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
2858 | return writeDouble(this, value, offset, false, noAssert)
|
2859 | }
|
2860 |
|
2861 |
|
2862 | Buffer.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 |
|
2871 | if (end === start) return 0
|
2872 | if (target.length === 0 || this.length === 0) return 0
|
2873 |
|
2874 |
|
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 |
|
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 |
|
2891 | this.copyWithin(targetStart, start, end)
|
2892 | } else if (this === target && start < targetStart && targetStart < end) {
|
2893 |
|
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 |
|
2909 |
|
2910 |
|
2911 |
|
2912 | Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
2913 |
|
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 |
|
2934 | val = code
|
2935 | }
|
2936 | }
|
2937 | } else if (typeof val === 'number') {
|
2938 | val = val & 255
|
2939 | }
|
2940 |
|
2941 |
|
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 |
|
2978 |
|
2979 |
|
2980 | var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
|
2981 |
|
2982 | function base64clean (str) {
|
2983 |
|
2984 | str = str.split('=')[0]
|
2985 |
|
2986 | str = str.trim().replace(INVALID_BASE64_RE, '')
|
2987 |
|
2988 | if (str.length < 2) return ''
|
2989 |
|
2990 | while (str.length % 4 !== 0) {
|
2991 | str = str + '='
|
2992 | }
|
2993 | return str
|
2994 | }
|
2995 |
|
2996 | function toHex (n) {
|
2997 | if (n < 16) return '0' + n.toString(16)
|
2998 | return n.toString(16)
|
2999 | }
|
3000 |
|
3001 | function 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 |
|
3012 | if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
3013 |
|
3014 | if (!leadSurrogate) {
|
3015 |
|
3016 | if (codePoint > 0xDBFF) {
|
3017 |
|
3018 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3019 | continue
|
3020 | } else if (i + 1 === length) {
|
3021 |
|
3022 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3023 | continue
|
3024 | }
|
3025 |
|
3026 |
|
3027 | leadSurrogate = codePoint
|
3028 |
|
3029 | continue
|
3030 | }
|
3031 |
|
3032 |
|
3033 | if (codePoint < 0xDC00) {
|
3034 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3035 | leadSurrogate = codePoint
|
3036 | continue
|
3037 | }
|
3038 |
|
3039 |
|
3040 | codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
3041 | } else if (leadSurrogate) {
|
3042 |
|
3043 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3044 | }
|
3045 |
|
3046 | leadSurrogate = null
|
3047 |
|
3048 |
|
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 |
|
3081 | function asciiToBytes (str) {
|
3082 | var byteArray = []
|
3083 | for (var i = 0; i < str.length; ++i) {
|
3084 |
|
3085 | byteArray.push(str.charCodeAt(i) & 0xFF)
|
3086 | }
|
3087 | return byteArray
|
3088 | }
|
3089 |
|
3090 | function 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 |
|
3106 | function base64ToBytes (str) {
|
3107 | return base64.toByteArray(base64clean(str))
|
3108 | }
|
3109 |
|
3110 | function 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 |
|
3119 |
|
3120 |
|
3121 | function 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 | }
|
3126 | function numberIsNaN (obj) {
|
3127 |
|
3128 | return obj !== obj
|
3129 | }
|
3130 |
|
3131 | },{"base64-js":6,"ieee754":67}],10:[function(require,module,exports){
|
3132 | module.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 |
|
3201 | var next = (global.process && process.nextTick) || global.setImmediate || function (f) {
|
3202 | setTimeout(f, 0)
|
3203 | }
|
3204 |
|
3205 | module.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){
|
3223 | require('../modules/es6.symbol');
|
3224 | require('../modules/es6.object.to-string');
|
3225 | module.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){
|
3228 | module.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){
|
3234 | var isObject = require('./_is-object');
|
3235 | module.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 |
|
3242 |
|
3243 | var toIObject = require('./_to-iobject');
|
3244 | var toLength = require('./_to-length');
|
3245 | var toAbsoluteIndex = require('./_to-absolute-index');
|
3246 | module.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 |
|
3253 |
|
3254 | if (IS_INCLUDES && el != el) while (length > index) {
|
3255 | value = O[index++];
|
3256 |
|
3257 | if (value != value) return true;
|
3258 |
|
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 |
|
3267 | var cof = require('./_cof');
|
3268 | var TAG = require('./_wks')('toStringTag');
|
3269 |
|
3270 | var ARG = cof(function () { return arguments; }()) == 'Arguments';
|
3271 |
|
3272 |
|
3273 | var tryGet = function (it, key) {
|
3274 | try {
|
3275 | return it[key];
|
3276 | } catch (e) { }
|
3277 | };
|
3278 |
|
3279 | module.exports = function (it) {
|
3280 | var O, T, B;
|
3281 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
3282 |
|
3283 | : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
|
3284 |
|
3285 | : ARG ? cof(O)
|
3286 |
|
3287 | : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
3288 | };
|
3289 |
|
3290 | },{"./_cof":17,"./_wks":60}],17:[function(require,module,exports){
|
3291 | var toString = {}.toString;
|
3292 |
|
3293 | module.exports = function (it) {
|
3294 | return toString.call(it).slice(8, -1);
|
3295 | };
|
3296 |
|
3297 | },{}],18:[function(require,module,exports){
|
3298 | var core = module.exports = { version: '2.6.3' };
|
3299 | if (typeof __e == 'number') __e = core;
|
3300 |
|
3301 | },{}],19:[function(require,module,exports){
|
3302 |
|
3303 | var aFunction = require('./_a-function');
|
3304 | module.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 |
|
3325 | module.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 |
|
3332 | module.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){
|
3337 | var isObject = require('./_is-object');
|
3338 | var document = require('./_global').document;
|
3339 |
|
3340 | var is = isObject(document) && isObject(document.createElement);
|
3341 | module.exports = function (it) {
|
3342 | return is ? document.createElement(it) : {};
|
3343 | };
|
3344 |
|
3345 | },{"./_global":27,"./_is-object":34}],23:[function(require,module,exports){
|
3346 |
|
3347 | module.exports = (
|
3348 | 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
|
3349 | ).split(',');
|
3350 |
|
3351 | },{}],24:[function(require,module,exports){
|
3352 |
|
3353 | var getKeys = require('./_object-keys');
|
3354 | var gOPS = require('./_object-gops');
|
3355 | var pIE = require('./_object-pie');
|
3356 | module.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){
|
3369 | var global = require('./_global');
|
3370 | var core = require('./_core');
|
3371 | var hide = require('./_hide');
|
3372 | var redefine = require('./_redefine');
|
3373 | var ctx = require('./_ctx');
|
3374 | var PROTOTYPE = 'prototype';
|
3375 |
|
3376 | var $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 |
|
3389 | own = !IS_FORCED && target && target[key] !== undefined;
|
3390 |
|
3391 | out = (own ? target : source)[key];
|
3392 |
|
3393 | exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
|
3394 |
|
3395 | if (target) redefine(target, key, out, type & $export.U);
|
3396 |
|
3397 | if (exports[key] != out) hide(exports, key, exp);
|
3398 | if (IS_PROTO && expProto[key] != out) expProto[key] = out;
|
3399 | }
|
3400 | };
|
3401 | global.core = core;
|
3402 |
|
3403 | $export.F = 1;
|
3404 | $export.G = 2;
|
3405 | $export.S = 4;
|
3406 | $export.P = 8;
|
3407 | $export.B = 16;
|
3408 | $export.W = 32;
|
3409 | $export.U = 64;
|
3410 | $export.R = 128;
|
3411 | module.exports = $export;
|
3412 |
|
3413 | },{"./_core":18,"./_ctx":19,"./_global":27,"./_hide":29,"./_redefine":48}],26:[function(require,module,exports){
|
3414 | module.exports = function (exec) {
|
3415 | try {
|
3416 | return !!exec();
|
3417 | } catch (e) {
|
3418 | return true;
|
3419 | }
|
3420 | };
|
3421 |
|
3422 | },{}],27:[function(require,module,exports){
|
3423 |
|
3424 | var global = module.exports = typeof window != 'undefined' && window.Math == Math
|
3425 | ? window : typeof self != 'undefined' && self.Math == Math ? self
|
3426 |
|
3427 | : Function('return this')();
|
3428 | if (typeof __g == 'number') __g = global;
|
3429 |
|
3430 | },{}],28:[function(require,module,exports){
|
3431 | var hasOwnProperty = {}.hasOwnProperty;
|
3432 | module.exports = function (it, key) {
|
3433 | return hasOwnProperty.call(it, key);
|
3434 | };
|
3435 |
|
3436 | },{}],29:[function(require,module,exports){
|
3437 | var dP = require('./_object-dp');
|
3438 | var createDesc = require('./_property-desc');
|
3439 | module.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){
|
3447 | var document = require('./_global').document;
|
3448 | module.exports = document && document.documentElement;
|
3449 |
|
3450 | },{"./_global":27}],31:[function(require,module,exports){
|
3451 | module.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 |
|
3457 | var cof = require('./_cof');
|
3458 |
|
3459 | module.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 |
|
3465 | var cof = require('./_cof');
|
3466 | module.exports = Array.isArray || function isArray(arg) {
|
3467 | return cof(arg) == 'Array';
|
3468 | };
|
3469 |
|
3470 | },{"./_cof":17}],34:[function(require,module,exports){
|
3471 | module.exports = function (it) {
|
3472 | return typeof it === 'object' ? it !== null : typeof it === 'function';
|
3473 | };
|
3474 |
|
3475 | },{}],35:[function(require,module,exports){
|
3476 | module.exports = false;
|
3477 |
|
3478 | },{}],36:[function(require,module,exports){
|
3479 | var META = require('./_uid')('meta');
|
3480 | var isObject = require('./_is-object');
|
3481 | var has = require('./_has');
|
3482 | var setDesc = require('./_object-dp').f;
|
3483 | var id = 0;
|
3484 | var isExtensible = Object.isExtensible || function () {
|
3485 | return true;
|
3486 | };
|
3487 | var FREEZE = !require('./_fails')(function () {
|
3488 | return isExtensible(Object.preventExtensions({}));
|
3489 | });
|
3490 | var setMeta = function (it) {
|
3491 | setDesc(it, META, { value: {
|
3492 | i: 'O' + ++id,
|
3493 | w: {}
|
3494 | } });
|
3495 | };
|
3496 | var fastKey = function (it, create) {
|
3497 |
|
3498 | if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
3499 | if (!has(it, META)) {
|
3500 |
|
3501 | if (!isExtensible(it)) return 'F';
|
3502 |
|
3503 | if (!create) return 'E';
|
3504 |
|
3505 | setMeta(it);
|
3506 |
|
3507 | } return it[META].i;
|
3508 | };
|
3509 | var getWeak = function (it, create) {
|
3510 | if (!has(it, META)) {
|
3511 |
|
3512 | if (!isExtensible(it)) return true;
|
3513 |
|
3514 | if (!create) return false;
|
3515 |
|
3516 | setMeta(it);
|
3517 |
|
3518 | } return it[META].w;
|
3519 | };
|
3520 |
|
3521 | var onFreeze = function (it) {
|
3522 | if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
|
3523 | return it;
|
3524 | };
|
3525 | var 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 |
|
3535 | var anObject = require('./_an-object');
|
3536 | var dPs = require('./_object-dps');
|
3537 | var enumBugKeys = require('./_enum-bug-keys');
|
3538 | var IE_PROTO = require('./_shared-key')('IE_PROTO');
|
3539 | var Empty = function () { };
|
3540 | var PROTOTYPE = 'prototype';
|
3541 |
|
3542 |
|
3543 | var createDict = function () {
|
3544 |
|
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:';
|
3553 |
|
3554 |
|
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 |
|
3564 | module.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 |
|
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){
|
3577 | var anObject = require('./_an-object');
|
3578 | var IE8_DOM_DEFINE = require('./_ie8-dom-define');
|
3579 | var toPrimitive = require('./_to-primitive');
|
3580 | var dP = Object.defineProperty;
|
3581 |
|
3582 | exports.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) { }
|
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){
|
3595 | var dP = require('./_object-dp');
|
3596 | var anObject = require('./_an-object');
|
3597 | var getKeys = require('./_object-keys');
|
3598 |
|
3599 | module.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){
|
3610 | var pIE = require('./_object-pie');
|
3611 | var createDesc = require('./_property-desc');
|
3612 | var toIObject = require('./_to-iobject');
|
3613 | var toPrimitive = require('./_to-primitive');
|
3614 | var has = require('./_has');
|
3615 | var IE8_DOM_DEFINE = require('./_ie8-dom-define');
|
3616 | var gOPD = Object.getOwnPropertyDescriptor;
|
3617 |
|
3618 | exports.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) { }
|
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 |
|
3629 | var toIObject = require('./_to-iobject');
|
3630 | var gOPN = require('./_object-gopn').f;
|
3631 | var toString = {}.toString;
|
3632 |
|
3633 | var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
|
3634 | ? Object.getOwnPropertyNames(window) : [];
|
3635 |
|
3636 | var getWindowNames = function (it) {
|
3637 | try {
|
3638 | return gOPN(it);
|
3639 | } catch (e) {
|
3640 | return windowNames.slice();
|
3641 | }
|
3642 | };
|
3643 |
|
3644 | module.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 |
|
3650 | var $keys = require('./_object-keys-internal');
|
3651 | var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
|
3652 |
|
3653 | exports.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){
|
3658 | exports.f = Object.getOwnPropertySymbols;
|
3659 |
|
3660 | },{}],44:[function(require,module,exports){
|
3661 | var has = require('./_has');
|
3662 | var toIObject = require('./_to-iobject');
|
3663 | var arrayIndexOf = require('./_array-includes')(false);
|
3664 | var IE_PROTO = require('./_shared-key')('IE_PROTO');
|
3665 |
|
3666 | module.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 |
|
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 |
|
3681 | var $keys = require('./_object-keys-internal');
|
3682 | var enumBugKeys = require('./_enum-bug-keys');
|
3683 |
|
3684 | module.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){
|
3689 | exports.f = {}.propertyIsEnumerable;
|
3690 |
|
3691 | },{}],47:[function(require,module,exports){
|
3692 | module.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){
|
3702 | var global = require('./_global');
|
3703 | var hide = require('./_hide');
|
3704 | var has = require('./_has');
|
3705 | var SRC = require('./_uid')('src');
|
3706 | var TO_STRING = 'toString';
|
3707 | var $toString = Function[TO_STRING];
|
3708 | var TPL = ('' + $toString).split(TO_STRING);
|
3709 |
|
3710 | require('./_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 |
|
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){
|
3735 | var def = require('./_object-dp').f;
|
3736 | var has = require('./_has');
|
3737 | var TAG = require('./_wks')('toStringTag');
|
3738 |
|
3739 | module.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){
|
3744 | var shared = require('./_shared')('keys');
|
3745 | var uid = require('./_uid');
|
3746 | module.exports = function (key) {
|
3747 | return shared[key] || (shared[key] = uid(key));
|
3748 | };
|
3749 |
|
3750 | },{"./_shared":51,"./_uid":57}],51:[function(require,module,exports){
|
3751 | var core = require('./_core');
|
3752 | var global = require('./_global');
|
3753 | var SHARED = '__core-js_shared__';
|
3754 | var 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){
|
3765 | var toInteger = require('./_to-integer');
|
3766 | var max = Math.max;
|
3767 | var min = Math.min;
|
3768 | module.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 |
|
3775 | var ceil = Math.ceil;
|
3776 | var floor = Math.floor;
|
3777 | module.exports = function (it) {
|
3778 | return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
3779 | };
|
3780 |
|
3781 | },{}],54:[function(require,module,exports){
|
3782 |
|
3783 | var IObject = require('./_iobject');
|
3784 | var defined = require('./_defined');
|
3785 | module.exports = function (it) {
|
3786 | return IObject(defined(it));
|
3787 | };
|
3788 |
|
3789 | },{"./_defined":20,"./_iobject":32}],55:[function(require,module,exports){
|
3790 |
|
3791 | var toInteger = require('./_to-integer');
|
3792 | var min = Math.min;
|
3793 | module.exports = function (it) {
|
3794 | return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
|
3795 | };
|
3796 |
|
3797 | },{"./_to-integer":53}],56:[function(require,module,exports){
|
3798 |
|
3799 | var isObject = require('./_is-object');
|
3800 |
|
3801 |
|
3802 | module.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){
|
3812 | var id = 0;
|
3813 | var px = Math.random();
|
3814 | module.exports = function (key) {
|
3815 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
3816 | };
|
3817 |
|
3818 | },{}],58:[function(require,module,exports){
|
3819 | var global = require('./_global');
|
3820 | var core = require('./_core');
|
3821 | var LIBRARY = require('./_library');
|
3822 | var wksExt = require('./_wks-ext');
|
3823 | var defineProperty = require('./_object-dp').f;
|
3824 | module.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){
|
3830 | exports.f = require('./_wks');
|
3831 |
|
3832 | },{"./_wks":60}],60:[function(require,module,exports){
|
3833 | var store = require('./_shared')('wks');
|
3834 | var uid = require('./_uid');
|
3835 | var Symbol = require('./_global').Symbol;
|
3836 | var USE_SYMBOL = typeof Symbol == 'function';
|
3837 |
|
3838 | var $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 |
|
3848 | var classof = require('./_classof');
|
3849 | var test = {};
|
3850 | test[require('./_wks')('toStringTag')] = 'z';
|
3851 | if (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 |
|
3860 | var global = require('./_global');
|
3861 | var has = require('./_has');
|
3862 | var DESCRIPTORS = require('./_descriptors');
|
3863 | var $export = require('./_export');
|
3864 | var redefine = require('./_redefine');
|
3865 | var META = require('./_meta').KEY;
|
3866 | var $fails = require('./_fails');
|
3867 | var shared = require('./_shared');
|
3868 | var setToStringTag = require('./_set-to-string-tag');
|
3869 | var uid = require('./_uid');
|
3870 | var wks = require('./_wks');
|
3871 | var wksExt = require('./_wks-ext');
|
3872 | var wksDefine = require('./_wks-define');
|
3873 | var enumKeys = require('./_enum-keys');
|
3874 | var isArray = require('./_is-array');
|
3875 | var anObject = require('./_an-object');
|
3876 | var isObject = require('./_is-object');
|
3877 | var toIObject = require('./_to-iobject');
|
3878 | var toPrimitive = require('./_to-primitive');
|
3879 | var createDesc = require('./_property-desc');
|
3880 | var _create = require('./_object-create');
|
3881 | var gOPNExt = require('./_object-gopn-ext');
|
3882 | var $GOPD = require('./_object-gopd');
|
3883 | var $DP = require('./_object-dp');
|
3884 | var $keys = require('./_object-keys');
|
3885 | var gOPD = $GOPD.f;
|
3886 | var dP = $DP.f;
|
3887 | var gOPN = gOPNExt.f;
|
3888 | var $Symbol = global.Symbol;
|
3889 | var $JSON = global.JSON;
|
3890 | var _stringify = $JSON && $JSON.stringify;
|
3891 | var PROTOTYPE = 'prototype';
|
3892 | var HIDDEN = wks('_hidden');
|
3893 | var TO_PRIMITIVE = wks('toPrimitive');
|
3894 | var isEnum = {}.propertyIsEnumerable;
|
3895 | var SymbolRegistry = shared('symbol-registry');
|
3896 | var AllSymbols = shared('symbols');
|
3897 | var OPSymbols = shared('op-symbols');
|
3898 | var ObjectProto = Object[PROTOTYPE];
|
3899 | var USE_NATIVE = typeof $Symbol == 'function';
|
3900 | var QObject = global.QObject;
|
3901 |
|
3902 | var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
|
3903 |
|
3904 |
|
3905 | var 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 |
|
3916 | var wrap = function (tag) {
|
3917 | var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
|
3918 | sym._k = tag;
|
3919 | return sym;
|
3920 | };
|
3921 |
|
3922 | var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
|
3923 | return typeof it == 'symbol';
|
3924 | } : function (it) {
|
3925 | return it instanceof $Symbol;
|
3926 | };
|
3927 |
|
3928 | var $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 | };
|
3943 | var $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 | };
|
3952 | var $create = function create(it, P) {
|
3953 | return P === undefined ? _create(it) : $defineProperties(_create(it), P);
|
3954 | };
|
3955 | var $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 | };
|
3960 | var $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 | };
|
3968 | var $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 | };
|
3977 | var $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 |
|
3989 | if (!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 |
|
4022 | for (var es6Symbols = (
|
4023 |
|
4024 | 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
|
4025 | ).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
|
4026 |
|
4027 | for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
|
4028 |
|
4029 | $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
|
4030 |
|
4031 | 'for': function (key) {
|
4032 | return has(SymbolRegistry, key += '')
|
4033 | ? SymbolRegistry[key]
|
4034 | : SymbolRegistry[key] = $Symbol(key);
|
4035 | },
|
4036 |
|
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 |
|
4047 | create: $create,
|
4048 |
|
4049 | defineProperty: $defineProperty,
|
4050 |
|
4051 | defineProperties: $defineProperties,
|
4052 |
|
4053 | getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
|
4054 |
|
4055 | getOwnPropertyNames: $getOwnPropertyNames,
|
4056 |
|
4057 | getOwnPropertySymbols: $getOwnPropertySymbols
|
4058 | });
|
4059 |
|
4060 |
|
4061 | $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
|
4062 | var S = $Symbol();
|
4063 |
|
4064 |
|
4065 |
|
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;
|
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 |
|
4085 | $Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
|
4086 |
|
4087 | setToStringTag($Symbol, 'Symbol');
|
4088 |
|
4089 | setToStringTag(Math, 'Math', true);
|
4090 |
|
4091 | setToStringTag(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 |
|
4096 |
|
4097 |
|
4098 |
|
4099 |
|
4100 |
|
4101 |
|
4102 |
|
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 |
|
4108 |
|
4109 |
|
4110 |
|
4111 |
|
4112 |
|
4113 |
|
4114 |
|
4115 |
|
4116 |
|
4117 |
|
4118 |
|
4119 | function isArray(arg) {
|
4120 | if (Array.isArray) {
|
4121 | return Array.isArray(arg);
|
4122 | }
|
4123 | return objectToString(arg) === '[object Array]';
|
4124 | }
|
4125 | exports.isArray = isArray;
|
4126 |
|
4127 | function isBoolean(arg) {
|
4128 | return typeof arg === 'boolean';
|
4129 | }
|
4130 | exports.isBoolean = isBoolean;
|
4131 |
|
4132 | function isNull(arg) {
|
4133 | return arg === null;
|
4134 | }
|
4135 | exports.isNull = isNull;
|
4136 |
|
4137 | function isNullOrUndefined(arg) {
|
4138 | return arg == null;
|
4139 | }
|
4140 | exports.isNullOrUndefined = isNullOrUndefined;
|
4141 |
|
4142 | function isNumber(arg) {
|
4143 | return typeof arg === 'number';
|
4144 | }
|
4145 | exports.isNumber = isNumber;
|
4146 |
|
4147 | function isString(arg) {
|
4148 | return typeof arg === 'string';
|
4149 | }
|
4150 | exports.isString = isString;
|
4151 |
|
4152 | function isSymbol(arg) {
|
4153 | return typeof arg === 'symbol';
|
4154 | }
|
4155 | exports.isSymbol = isSymbol;
|
4156 |
|
4157 | function isUndefined(arg) {
|
4158 | return arg === void 0;
|
4159 | }
|
4160 | exports.isUndefined = isUndefined;
|
4161 |
|
4162 | function isRegExp(re) {
|
4163 | return objectToString(re) === '[object RegExp]';
|
4164 | }
|
4165 | exports.isRegExp = isRegExp;
|
4166 |
|
4167 | function isObject(arg) {
|
4168 | return typeof arg === 'object' && arg !== null;
|
4169 | }
|
4170 | exports.isObject = isObject;
|
4171 |
|
4172 | function isDate(d) {
|
4173 | return objectToString(d) === '[object Date]';
|
4174 | }
|
4175 | exports.isDate = isDate;
|
4176 |
|
4177 | function isError(e) {
|
4178 | return (objectToString(e) === '[object Error]' || e instanceof Error);
|
4179 | }
|
4180 | exports.isError = isError;
|
4181 |
|
4182 | function isFunction(arg) {
|
4183 | return typeof arg === 'function';
|
4184 | }
|
4185 | exports.isFunction = isFunction;
|
4186 |
|
4187 | function isPrimitive(arg) {
|
4188 | return arg === null ||
|
4189 | typeof arg === 'boolean' ||
|
4190 | typeof arg === 'number' ||
|
4191 | typeof arg === 'string' ||
|
4192 | typeof arg === 'symbol' ||
|
4193 | typeof arg === 'undefined';
|
4194 | }
|
4195 | exports.isPrimitive = isPrimitive;
|
4196 |
|
4197 | exports.isBuffer = Buffer.isBuffer;
|
4198 |
|
4199 | function 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 |
|
4207 |
|
4208 |
|
4209 |
|
4210 |
|
4211 |
|
4212 |
|
4213 |
|
4214 |
|
4215 |
|
4216 |
|
4217 |
|
4218 |
|
4219 |
|
4220 |
|
4221 |
|
4222 |
|
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 | var objectCreate = Object.create || objectCreatePolyfill
|
4228 | var objectKeys = Object.keys || objectKeysPolyfill
|
4229 | var bind = Function.prototype.bind || functionBindPolyfill
|
4230 |
|
4231 | function 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 | }
|
4239 | module.exports = EventEmitter;
|
4240 |
|
4241 |
|
4242 | EventEmitter.EventEmitter = EventEmitter;
|
4243 |
|
4244 | EventEmitter.prototype._events = undefined;
|
4245 | EventEmitter.prototype._maxListeners = undefined;
|
4246 |
|
4247 |
|
4248 |
|
4249 | var defaultMaxListeners = 10;
|
4250 |
|
4251 | var hasDefineProperty;
|
4252 | try {
|
4253 | var o = {};
|
4254 | if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
|
4255 | hasDefineProperty = o.x === 0;
|
4256 | } catch (err) { hasDefineProperty = false }
|
4257 | if (hasDefineProperty) {
|
4258 | Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
4259 | enumerable: true,
|
4260 | get: function() {
|
4261 | return defaultMaxListeners;
|
4262 | },
|
4263 | set: function(arg) {
|
4264 |
|
4265 |
|
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 |
|
4276 |
|
4277 | EventEmitter.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 |
|
4284 | function $getMaxListeners(that) {
|
4285 | if (that._maxListeners === undefined)
|
4286 | return EventEmitter.defaultMaxListeners;
|
4287 | return that._maxListeners;
|
4288 | }
|
4289 |
|
4290 | EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
4291 | return $getMaxListeners(this);
|
4292 | };
|
4293 |
|
4294 |
|
4295 |
|
4296 |
|
4297 |
|
4298 |
|
4299 | function 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 | }
|
4309 | function 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 | }
|
4319 | function 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 | }
|
4329 | function 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 |
|
4340 | function 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 |
|
4351 | EventEmitter.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 |
|
4362 | if (doError) {
|
4363 | if (arguments.length > 1)
|
4364 | er = arguments[1];
|
4365 | if (er instanceof Error) {
|
4366 | throw er;
|
4367 | } else {
|
4368 |
|
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 |
|
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 |
|
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 |
|
4408 | function _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 |
|
4422 |
|
4423 | if (events.newListener) {
|
4424 | target.emit('newListener', type,
|
4425 | listener.listener ? listener.listener : listener);
|
4426 |
|
4427 |
|
4428 |
|
4429 | events = target._events;
|
4430 | }
|
4431 | existing = events[type];
|
4432 | }
|
4433 |
|
4434 | if (!existing) {
|
4435 |
|
4436 | existing = events[type] = listener;
|
4437 | ++target._eventsCount;
|
4438 | } else {
|
4439 | if (typeof existing === 'function') {
|
4440 |
|
4441 | existing = events[type] =
|
4442 | prepend ? [listener, existing] : [existing, listener];
|
4443 | } else {
|
4444 |
|
4445 | if (prepend) {
|
4446 | existing.unshift(listener);
|
4447 | } else {
|
4448 | existing.push(listener);
|
4449 | }
|
4450 | }
|
4451 |
|
4452 |
|
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 |
|
4475 | EventEmitter.prototype.addListener = function addListener(type, listener) {
|
4476 | return _addListener(this, type, listener, false);
|
4477 | };
|
4478 |
|
4479 | EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
4480 |
|
4481 | EventEmitter.prototype.prependListener =
|
4482 | function prependListener(type, listener) {
|
4483 | return _addListener(this, type, listener, true);
|
4484 | };
|
4485 |
|
4486 | function 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 |
|
4509 | function _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 |
|
4517 | EventEmitter.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 |
|
4524 | EventEmitter.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 |
|
4533 | EventEmitter.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 |
|
4585 | EventEmitter.prototype.removeAllListeners =
|
4586 | function removeAllListeners(type) {
|
4587 | var listeners, events, i;
|
4588 |
|
4589 | events = this._events;
|
4590 | if (!events)
|
4591 | return this;
|
4592 |
|
4593 |
|
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 |
|
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 |
|
4628 | for (i = listeners.length - 1; i >= 0; i--) {
|
4629 | this.removeListener(type, listeners[i]);
|
4630 | }
|
4631 | }
|
4632 |
|
4633 | return this;
|
4634 | };
|
4635 |
|
4636 | function _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 |
|
4652 | EventEmitter.prototype.listeners = function listeners(type) {
|
4653 | return _listeners(this, type, true);
|
4654 | };
|
4655 |
|
4656 | EventEmitter.prototype.rawListeners = function rawListeners(type) {
|
4657 | return _listeners(this, type, false);
|
4658 | };
|
4659 |
|
4660 | EventEmitter.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 |
|
4668 | EventEmitter.prototype.listenerCount = listenerCount;
|
4669 | function 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 |
|
4685 | EventEmitter.prototype.eventNames = function eventNames() {
|
4686 | return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
4687 | };
|
4688 |
|
4689 |
|
4690 | function 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 |
|
4696 | function 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 |
|
4703 | function 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 |
|
4711 | function objectCreatePolyfill(proto) {
|
4712 | var F = function() {};
|
4713 | F.prototype = proto;
|
4714 | return new F;
|
4715 | }
|
4716 | function 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 | }
|
4723 | function functionBindPolyfill(context) {
|
4724 | var fn = this;
|
4725 | return function () {
|
4726 | return fn.apply(context, arguments);
|
4727 | };
|
4728 | }
|
4729 |
|
4730 | },{}],65:[function(require,module,exports){
|
4731 | function 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 |
|
4757 | if(args.length) {
|
4758 | fmt += ' ' + args.join(' ');
|
4759 | }
|
4760 |
|
4761 |
|
4762 | fmt = fmt.replace(/%{2,2}/g, '%');
|
4763 |
|
4764 | return '' + fmt;
|
4765 | }
|
4766 |
|
4767 | module.exports = format;
|
4768 |
|
4769 | },{}],66:[function(require,module,exports){
|
4770 | var http = require('http')
|
4771 | var url = require('url')
|
4772 |
|
4773 | var https = module.exports
|
4774 |
|
4775 | for (var key in http) {
|
4776 | if (http.hasOwnProperty(key)) https[key] = http[key]
|
4777 | }
|
4778 |
|
4779 | https.request = function (params, cb) {
|
4780 | params = validateParams(params)
|
4781 | return http.request.call(this, params, cb)
|
4782 | }
|
4783 |
|
4784 | https.get = function (params, cb) {
|
4785 | params = validateParams(params)
|
4786 | return http.get.call(this, params, cb)
|
4787 | }
|
4788 |
|
4789 | function 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){
|
4803 | exports.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 |
|
4836 | exports.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){
|
4889 | if (typeof Object.create === 'function') {
|
4890 |
|
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 |
|
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 |
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 | module.exports = function (obj) {
|
4924 | return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
|
4925 | }
|
4926 |
|
4927 | function isBuffer (obj) {
|
4928 | return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
|
4929 | }
|
4930 |
|
4931 |
|
4932 | function 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){
|
4937 | var toString = {}.toString;
|
4938 |
|
4939 | module.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 |
|
4947 | var yaml = require('./lib/js-yaml.js');
|
4948 |
|
4949 |
|
4950 | module.exports = yaml;
|
4951 |
|
4952 | },{"./lib/js-yaml.js":72}],72:[function(require,module,exports){
|
4953 | 'use strict';
|
4954 |
|
4955 |
|
4956 | var loader = require('./js-yaml/loader');
|
4957 | var dumper = require('./js-yaml/dumper');
|
4958 |
|
4959 |
|
4960 | function deprecated(name) {
|
4961 | return function () {
|
4962 | throw new Error('Function ' + name + ' is deprecated and cannot be used.');
|
4963 | };
|
4964 | }
|
4965 |
|
4966 |
|
4967 | module.exports.Type = require('./js-yaml/type');
|
4968 | module.exports.Schema = require('./js-yaml/schema');
|
4969 | module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
|
4970 | module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
|
4971 | module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
|
4972 | module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
4973 | module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
|
4974 | module.exports.load = loader.load;
|
4975 | module.exports.loadAll = loader.loadAll;
|
4976 | module.exports.safeLoad = loader.safeLoad;
|
4977 | module.exports.safeLoadAll = loader.safeLoadAll;
|
4978 | module.exports.dump = dumper.dump;
|
4979 | module.exports.safeDump = dumper.safeDump;
|
4980 | module.exports.YAMLException = require('./js-yaml/exception');
|
4981 |
|
4982 |
|
4983 | module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
|
4984 | module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
4985 | module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
|
4986 |
|
4987 |
|
4988 | module.exports.scan = deprecated('scan');
|
4989 | module.exports.parse = deprecated('parse');
|
4990 | module.exports.compose = deprecated('compose');
|
4991 | module.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 |
|
4997 | function isNothing(subject) {
|
4998 | return (typeof subject === 'undefined') || (subject === null);
|
4999 | }
|
5000 |
|
5001 |
|
5002 | function isObject(subject) {
|
5003 | return (typeof subject === 'object') && (subject !== null);
|
5004 | }
|
5005 |
|
5006 |
|
5007 | function toArray(sequence) {
|
5008 | if (Array.isArray(sequence)) return sequence;
|
5009 | else if (isNothing(sequence)) return [];
|
5010 |
|
5011 | return [ sequence ];
|
5012 | }
|
5013 |
|
5014 |
|
5015 | function 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 |
|
5031 | function 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 |
|
5042 | function isNegativeZero(number) {
|
5043 | return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
|
5044 | }
|
5045 |
|
5046 |
|
5047 | module.exports.isNothing = isNothing;
|
5048 | module.exports.isObject = isObject;
|
5049 | module.exports.toArray = toArray;
|
5050 | module.exports.repeat = repeat;
|
5051 | module.exports.isNegativeZero = isNegativeZero;
|
5052 | module.exports.extend = extend;
|
5053 |
|
5054 | },{}],74:[function(require,module,exports){
|
5055 | 'use strict';
|
5056 |
|
5057 |
|
5058 |
|
5059 | var common = require('./common');
|
5060 | var YAMLException = require('./exception');
|
5061 | var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
5062 | var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
5063 |
|
5064 | var _toString = Object.prototype.toString;
|
5065 | var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
5066 |
|
5067 | var CHAR_TAB = 0x09;
|
5068 | var CHAR_LINE_FEED = 0x0A;
|
5069 | var CHAR_SPACE = 0x20;
|
5070 | var CHAR_EXCLAMATION = 0x21;
|
5071 | var CHAR_DOUBLE_QUOTE = 0x22;
|
5072 | var CHAR_SHARP = 0x23;
|
5073 | var CHAR_PERCENT = 0x25;
|
5074 | var CHAR_AMPERSAND = 0x26;
|
5075 | var CHAR_SINGLE_QUOTE = 0x27;
|
5076 | var CHAR_ASTERISK = 0x2A;
|
5077 | var CHAR_COMMA = 0x2C;
|
5078 | var CHAR_MINUS = 0x2D;
|
5079 | var CHAR_COLON = 0x3A;
|
5080 | var CHAR_GREATER_THAN = 0x3E;
|
5081 | var CHAR_QUESTION = 0x3F;
|
5082 | var CHAR_COMMERCIAL_AT = 0x40;
|
5083 | var CHAR_LEFT_SQUARE_BRACKET = 0x5B;
|
5084 | var CHAR_RIGHT_SQUARE_BRACKET = 0x5D;
|
5085 | var CHAR_GRAVE_ACCENT = 0x60;
|
5086 | var CHAR_LEFT_CURLY_BRACKET = 0x7B;
|
5087 | var CHAR_VERTICAL_LINE = 0x7C;
|
5088 | var CHAR_RIGHT_CURLY_BRACKET = 0x7D;
|
5089 |
|
5090 | var ESCAPE_SEQUENCES = {};
|
5091 |
|
5092 | ESCAPE_SEQUENCES[0x00] = '\\0';
|
5093 | ESCAPE_SEQUENCES[0x07] = '\\a';
|
5094 | ESCAPE_SEQUENCES[0x08] = '\\b';
|
5095 | ESCAPE_SEQUENCES[0x09] = '\\t';
|
5096 | ESCAPE_SEQUENCES[0x0A] = '\\n';
|
5097 | ESCAPE_SEQUENCES[0x0B] = '\\v';
|
5098 | ESCAPE_SEQUENCES[0x0C] = '\\f';
|
5099 | ESCAPE_SEQUENCES[0x0D] = '\\r';
|
5100 | ESCAPE_SEQUENCES[0x1B] = '\\e';
|
5101 | ESCAPE_SEQUENCES[0x22] = '\\"';
|
5102 | ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
5103 | ESCAPE_SEQUENCES[0x85] = '\\N';
|
5104 | ESCAPE_SEQUENCES[0xA0] = '\\_';
|
5105 | ESCAPE_SEQUENCES[0x2028] = '\\L';
|
5106 | ESCAPE_SEQUENCES[0x2029] = '\\P';
|
5107 |
|
5108 | var DEPRECATED_BOOLEANS_SYNTAX = [
|
5109 | 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
5110 | 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
5111 | ];
|
5112 |
|
5113 | function 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 |
|
5140 | function 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 |
|
5161 | function 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 |
|
5185 | function 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 |
|
5211 | function generateNextLine(state, level) {
|
5212 | return '\n' + common.repeat(' ', state.indent * level);
|
5213 | }
|
5214 |
|
5215 | function 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 |
|
5230 | function isWhitespace(c) {
|
5231 | return c === CHAR_SPACE || c === CHAR_TAB;
|
5232 | }
|
5233 |
|
5234 |
|
5235 |
|
5236 |
|
5237 |
|
5238 | function isPrintable(c) {
|
5239 | return (0x00020 <= c && c <= 0x00007E)
|
5240 | || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
|
5241 | || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF )
|
5242 | || (0x10000 <= c && c <= 0x10FFFF);
|
5243 | }
|
5244 |
|
5245 |
|
5246 | function isPlainSafe(c) {
|
5247 |
|
5248 |
|
5249 | return isPrintable(c) && c !== 0xFEFF
|
5250 |
|
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 |
|
5262 | function isPlainSafeFirst(c) {
|
5263 |
|
5264 |
|
5265 | return isPrintable(c) && c !== 0xFEFF
|
5266 | && !isWhitespace(c)
|
5267 |
|
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 |
|
5293 | function needIndentIndicator(string) {
|
5294 | var leadingSpaceRe = /^\n* /;
|
5295 | return leadingSpaceRe.test(string);
|
5296 | }
|
5297 |
|
5298 | var STYLE_PLAIN = 1,
|
5299 | STYLE_SINGLE = 2,
|
5300 | STYLE_LITERAL = 3,
|
5301 | STYLE_FOLDED = 4,
|
5302 | STYLE_DOUBLE = 5;
|
5303 |
|
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 |
|
5309 |
|
5310 |
|
5311 | function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
5312 | var i;
|
5313 | var char;
|
5314 | var hasLineBreak = false;
|
5315 | var hasFoldableLine = false;
|
5316 | var shouldTrackWidth = lineWidth !== -1;
|
5317 | var previousLineBreak = -1;
|
5318 | var plain = isPlainSafeFirst(string.charCodeAt(0))
|
5319 | && !isWhitespace(string.charCodeAt(string.length - 1));
|
5320 |
|
5321 | if (singleLineOnly) {
|
5322 |
|
5323 |
|
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 |
|
5333 | for (i = 0; i < string.length; i++) {
|
5334 | char = string.charCodeAt(i);
|
5335 | if (char === CHAR_LINE_FEED) {
|
5336 | hasLineBreak = true;
|
5337 |
|
5338 | if (shouldTrackWidth) {
|
5339 | hasFoldableLine = hasFoldableLine ||
|
5340 |
|
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 |
|
5351 | hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
|
5352 | (i - previousLineBreak - 1 > lineWidth &&
|
5353 | string[previousLineBreak + 1] !== ' '));
|
5354 | }
|
5355 |
|
5356 |
|
5357 |
|
5358 | if (!hasLineBreak && !hasFoldableLine) {
|
5359 |
|
5360 |
|
5361 | return plain && !testAmbiguousType(string)
|
5362 | ? STYLE_PLAIN : STYLE_SINGLE;
|
5363 | }
|
5364 |
|
5365 | if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
5366 | return STYLE_DOUBLE;
|
5367 | }
|
5368 |
|
5369 |
|
5370 | return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
5371 | }
|
5372 |
|
5373 |
|
5374 |
|
5375 |
|
5376 |
|
5377 |
|
5378 |
|
5379 | function 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);
|
5390 |
|
5391 |
|
5392 |
|
5393 |
|
5394 |
|
5395 |
|
5396 |
|
5397 | var lineWidth = state.lineWidth === -1
|
5398 | ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
5399 |
|
5400 |
|
5401 | var singleLineOnly = iskey
|
5402 |
|
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 |
|
5428 | function blockHeader(string, indentPerLevel) {
|
5429 | var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
|
5430 |
|
5431 |
|
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 |
|
5440 | function dropEndingNewline(string) {
|
5441 | return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
|
5442 | }
|
5443 |
|
5444 |
|
5445 |
|
5446 | function foldString(string, width) {
|
5447 |
|
5448 |
|
5449 |
|
5450 |
|
5451 | var lineRe = /(\n+)([^\n]*)/g;
|
5452 |
|
5453 |
|
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 |
|
5461 | var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
|
5462 | var moreIndented;
|
5463 |
|
5464 |
|
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 |
|
5480 |
|
5481 |
|
5482 |
|
5483 | function foldLine(line, width) {
|
5484 | if (line === '' || line[0] === ' ') return line;
|
5485 |
|
5486 |
|
5487 | var breakRe = / [^ ]/g;
|
5488 | var match;
|
5489 |
|
5490 | var start = 0, end, curr = 0, next = 0;
|
5491 | var result = '';
|
5492 |
|
5493 |
|
5494 |
|
5495 |
|
5496 |
|
5497 | while ((match = breakRe.exec(line))) {
|
5498 | next = match.index;
|
5499 |
|
5500 | if (next - start > width) {
|
5501 | end = (curr > start) ? curr : next;
|
5502 | result += '\n' + line.slice(start, end);
|
5503 |
|
5504 | start = end + 1;
|
5505 | }
|
5506 | curr = next;
|
5507 | }
|
5508 |
|
5509 |
|
5510 |
|
5511 | result += '\n';
|
5512 |
|
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);
|
5520 | }
|
5521 |
|
5522 |
|
5523 | function 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 |
|
5531 | if (char >= 0xD800 && char <= 0xDBFF) {
|
5532 | nextChar = string.charCodeAt(i + 1);
|
5533 | if (nextChar >= 0xDC00 && nextChar <= 0xDFFF) {
|
5534 |
|
5535 | result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
|
5536 |
|
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 |
|
5549 | function 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 |
|
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 |
|
5567 | function 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 |
|
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 || '[]';
|
5592 | }
|
5593 |
|
5594 | function 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;
|
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;
|
5622 | }
|
5623 |
|
5624 | pairBuffer += state.dump;
|
5625 |
|
5626 |
|
5627 | _result += pairBuffer;
|
5628 | }
|
5629 |
|
5630 | state.tag = _tag;
|
5631 | state.dump = '{' + _result + '}';
|
5632 | }
|
5633 |
|
5634 | function 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 |
|
5646 | if (state.sortKeys === true) {
|
5647 |
|
5648 | objectKeyList.sort();
|
5649 | } else if (typeof state.sortKeys === 'function') {
|
5650 |
|
5651 | objectKeyList.sort(state.sortKeys);
|
5652 | } else if (state.sortKeys) {
|
5653 |
|
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;
|
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;
|
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 |
|
5701 | _result += pairBuffer;
|
5702 | }
|
5703 |
|
5704 | state.tag = _tag;
|
5705 | state.dump = _result || '{}';
|
5706 | }
|
5707 |
|
5708 | function 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 |
|
5744 |
|
5745 |
|
5746 | function 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 |
|
5821 | function 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 |
|
5835 | function 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 |
|
5864 | function 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 |
|
5876 | function safeDump(input, options) {
|
5877 | return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
5878 | }
|
5879 |
|
5880 | module.exports.dump = dump;
|
5881 | module.exports.safeDump = safeDump;
|
5882 |
|
5883 | },{"./common":73,"./exception":75,"./schema/default_full":80,"./schema/default_safe":81}],75:[function(require,module,exports){
|
5884 |
|
5885 |
|
5886 | 'use strict';
|
5887 |
|
5888 | function YAMLException(reason, mark) {
|
5889 |
|
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 |
|
5898 | if (Error.captureStackTrace) {
|
5899 |
|
5900 | Error.captureStackTrace(this, this.constructor);
|
5901 | } else {
|
5902 |
|
5903 | this.stack = (new Error()).stack || '';
|
5904 | }
|
5905 | }
|
5906 |
|
5907 |
|
5908 |
|
5909 | YAMLException.prototype = Object.create(Error.prototype);
|
5910 | YAMLException.prototype.constructor = YAMLException;
|
5911 |
|
5912 |
|
5913 | YAMLException.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 |
|
5926 | module.exports = YAMLException;
|
5927 |
|
5928 | },{}],76:[function(require,module,exports){
|
5929 | 'use strict';
|
5930 |
|
5931 |
|
5932 |
|
5933 | var common = require('./common');
|
5934 | var YAMLException = require('./exception');
|
5935 | var Mark = require('./mark');
|
5936 | var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
5937 | var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
5938 |
|
5939 |
|
5940 | var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
5941 |
|
5942 |
|
5943 | var CONTEXT_FLOW_IN = 1;
|
5944 | var CONTEXT_FLOW_OUT = 2;
|
5945 | var CONTEXT_BLOCK_IN = 3;
|
5946 | var CONTEXT_BLOCK_OUT = 4;
|
5947 |
|
5948 |
|
5949 | var CHOMPING_CLIP = 1;
|
5950 | var CHOMPING_STRIP = 2;
|
5951 | var CHOMPING_KEEP = 3;
|
5952 |
|
5953 |
|
5954 | var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
5955 | var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
5956 | var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
5957 | var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
5958 | var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
5959 |
|
5960 |
|
5961 | function is_EOL(c) {
|
5962 | return (c === 0x0A) || (c === 0x0D);
|
5963 | }
|
5964 |
|
5965 | function is_WHITE_SPACE(c) {
|
5966 | return (c === 0x09) || (c === 0x20);
|
5967 | }
|
5968 |
|
5969 | function is_WS_OR_EOL(c) {
|
5970 | return (c === 0x09) ||
|
5971 | (c === 0x20) ||
|
5972 | (c === 0x0A) ||
|
5973 | (c === 0x0D);
|
5974 | }
|
5975 |
|
5976 | function is_FLOW_INDICATOR(c) {
|
5977 | return c === 0x2C ||
|
5978 | c === 0x5B ||
|
5979 | c === 0x5D ||
|
5980 | c === 0x7B ||
|
5981 | c === 0x7D;
|
5982 | }
|
5983 |
|
5984 | function fromHexCode(c) {
|
5985 | var lc;
|
5986 |
|
5987 | if ((0x30 <= c) && (c <= 0x39)) {
|
5988 | return c - 0x30;
|
5989 | }
|
5990 |
|
5991 |
|
5992 | lc = c | 0x20;
|
5993 |
|
5994 | if ((0x61 <= lc) && (lc <= 0x66)) {
|
5995 | return lc - 0x61 + 10;
|
5996 | }
|
5997 |
|
5998 | return -1;
|
5999 | }
|
6000 |
|
6001 | function escapedHexLen(c) {
|
6002 | if (c === 0x78) { return 2; }
|
6003 | if (c === 0x75) { return 4; }
|
6004 | if (c === 0x55) { return 8; }
|
6005 | return 0;
|
6006 | }
|
6007 |
|
6008 | function fromDecimalCode(c) {
|
6009 | if ((0x30 <= c) && (c <= 0x39)) {
|
6010 | return c - 0x30;
|
6011 | }
|
6012 |
|
6013 | return -1;
|
6014 | }
|
6015 |
|
6016 | function simpleEscapeSequence(c) {
|
6017 |
|
6018 | return (c === 0x30) ? '\x00' :
|
6019 | (c === 0x61) ? '\x07' :
|
6020 | (c === 0x62) ? '\x08' :
|
6021 | (c === 0x74) ? '\x09' :
|
6022 | (c === 0x09) ? '\x09' :
|
6023 | (c === 0x6E) ? '\x0A' :
|
6024 | (c === 0x76) ? '\x0B' :
|
6025 | (c === 0x66) ? '\x0C' :
|
6026 | (c === 0x72) ? '\x0D' :
|
6027 | (c === 0x65) ? '\x1B' :
|
6028 | (c === 0x20) ? ' ' :
|
6029 | (c === 0x22) ? '\x22' :
|
6030 | (c === 0x2F) ? '/' :
|
6031 | (c === 0x5C) ? '\x5C' :
|
6032 | (c === 0x4E) ? '\x85' :
|
6033 | (c === 0x5F) ? '\xA0' :
|
6034 | (c === 0x4C) ? '\u2028' :
|
6035 | (c === 0x50) ? '\u2029' : '';
|
6036 | }
|
6037 |
|
6038 | function charFromCodepoint(c) {
|
6039 | if (c <= 0xFFFF) {
|
6040 | return String.fromCharCode(c);
|
6041 | }
|
6042 |
|
6043 |
|
6044 | return String.fromCharCode(
|
6045 | ((c - 0x010000) >> 10) + 0xD800,
|
6046 | ((c - 0x010000) & 0x03FF) + 0xDC00
|
6047 | );
|
6048 | }
|
6049 |
|
6050 | var simpleEscapeCheck = new Array(256);
|
6051 | var simpleEscapeMap = new Array(256);
|
6052 | for (var i = 0; i < 256; i++) {
|
6053 | simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
6054 | simpleEscapeMap[i] = simpleEscapeSequence(i);
|
6055 | }
|
6056 |
|
6057 |
|
6058 | function 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 |
|
6081 |
|
6082 |
|
6083 |
|
6084 |
|
6085 |
|
6086 |
|
6087 |
|
6088 |
|
6089 | }
|
6090 |
|
6091 |
|
6092 | function 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 |
|
6098 | function throwError(state, message) {
|
6099 | throw generateError(state, message);
|
6100 | }
|
6101 |
|
6102 | function throwWarning(state, message) {
|
6103 | if (state.onWarning) {
|
6104 | state.onWarning.call(null, generateError(state, message));
|
6105 | }
|
6106 | }
|
6107 |
|
6108 |
|
6109 | var 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 |
|
6172 | function 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 |
|
6194 | function 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 |
|
6213 | function 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 |
|
6245 | function readLineBreak(state) {
|
6246 | var ch;
|
6247 |
|
6248 | ch = state.input.charCodeAt(state.position);
|
6249 |
|
6250 | if (ch === 0x0A) {
|
6251 | state.position++;
|
6252 | } else if (ch === 0x0D) {
|
6253 | state.position++;
|
6254 | if (state.input.charCodeAt(state.position) === 0x0A) {
|
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 |
|
6265 | function 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 && ch !== 0x0D && 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) {
|
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 |
|
6303 | function testDocumentSeparator(state) {
|
6304 | var _position = state.position,
|
6305 | ch;
|
6306 |
|
6307 | ch = state.input.charCodeAt(_position);
|
6308 |
|
6309 |
|
6310 |
|
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 |
|
6327 | function 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 |
|
6336 | function 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 |
|
6445 | function 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 |
|
6490 | function 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 |
|
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 |
|
6569 | function 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 |
|
6674 | function 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)) {
|
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 |
|
6756 | if (state.lineIndent < textIndent) {
|
6757 |
|
6758 |
|
6759 | if (chomping === CHOMPING_KEEP) {
|
6760 | state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
6761 | } else if (chomping === CHOMPING_CLIP) {
|
6762 | if (didReadContent) {
|
6763 | state.result += '\n';
|
6764 | }
|
6765 | }
|
6766 |
|
6767 |
|
6768 | break;
|
6769 | }
|
6770 |
|
6771 |
|
6772 | if (folding) {
|
6773 |
|
6774 |
|
6775 | if (is_WHITE_SPACE(ch)) {
|
6776 | atMoreIndented = true;
|
6777 |
|
6778 | state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
6779 |
|
6780 |
|
6781 | } else if (atMoreIndented) {
|
6782 | atMoreIndented = false;
|
6783 | state.result += common.repeat('\n', emptyLines + 1);
|
6784 |
|
6785 |
|
6786 | } else if (emptyLines === 0) {
|
6787 | if (didReadContent) {
|
6788 | state.result += ' ';
|
6789 | }
|
6790 |
|
6791 |
|
6792 | } else {
|
6793 | state.result += common.repeat('\n', emptyLines);
|
6794 | }
|
6795 |
|
6796 |
|
6797 | } else {
|
6798 |
|
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 |
|
6817 | function 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 |
|
6879 | function 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;
|
6904 | _pos = state.position;
|
6905 |
|
6906 |
|
6907 |
|
6908 |
|
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 |
|
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 |
|
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;
|
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;
|
6980 | }
|
6981 |
|
6982 | } else {
|
6983 | break;
|
6984 | }
|
6985 |
|
6986 |
|
6987 |
|
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 |
|
7016 |
|
7017 |
|
7018 |
|
7019 | if (atExplicitKey) {
|
7020 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
7021 | }
|
7022 |
|
7023 |
|
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 |
|
7034 | function 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 |
|
7128 | function 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 |
|
7155 | function 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 |
|
7185 | function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
7186 | var allowBlockStyles,
|
7187 | allowBlockScalars,
|
7188 | allowBlockCollections,
|
7189 | indentStatus = 1,
|
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 |
|
7290 |
|
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 |
|
7301 |
|
7302 |
|
7303 |
|
7304 | if (type.resolve(state.result)) {
|
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)) {
|
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 |
|
7339 | function 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 |
|
7447 | function loadDocuments(input, options) {
|
7448 | input = String(input);
|
7449 | options = options || {};
|
7450 |
|
7451 | if (input.length !== 0) {
|
7452 |
|
7453 |
|
7454 | if (input.charCodeAt(input.length - 1) !== 0x0A &&
|
7455 | input.charCodeAt(input.length - 1) !== 0x0D) {
|
7456 | input += '\n';
|
7457 | }
|
7458 |
|
7459 |
|
7460 | if (input.charCodeAt(0) === 0xFEFF) {
|
7461 | input = input.slice(1);
|
7462 | }
|
7463 | }
|
7464 |
|
7465 | var state = new State(input, options);
|
7466 |
|
7467 |
|
7468 | state.input += '\0';
|
7469 |
|
7470 | while (state.input.charCodeAt(state.position) === 0x20) {
|
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 |
|
7483 | function 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 |
|
7496 | function load(input, options) {
|
7497 | var documents = loadDocuments(input, options);
|
7498 |
|
7499 | if (documents.length === 0) {
|
7500 |
|
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 |
|
7509 | function 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 |
|
7518 | function safeLoad(input, options) {
|
7519 | return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
7520 | }
|
7521 |
|
7522 |
|
7523 | module.exports.loadAll = loadAll;
|
7524 | module.exports.load = load;
|
7525 | module.exports.safeLoadAll = safeLoadAll;
|
7526 | module.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 |
|
7532 | var common = require('./common');
|
7533 |
|
7534 |
|
7535 | function 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 |
|
7544 | Mark.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 |
|
7583 | Mark.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 |
|
7604 | module.exports = Mark;
|
7605 |
|
7606 | },{"./common":73}],78:[function(require,module,exports){
|
7607 | 'use strict';
|
7608 |
|
7609 |
|
7610 |
|
7611 | var common = require('./common');
|
7612 | var YAMLException = require('./exception');
|
7613 | var Type = require('./type');
|
7614 |
|
7615 |
|
7616 | function 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 |
|
7639 | function 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 |
|
7658 | function 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 |
|
7675 | Schema.DEFAULT = null;
|
7676 |
|
7677 |
|
7678 | Schema.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 |
|
7714 | module.exports = Schema;
|
7715 |
|
7716 | },{"./common":73,"./exception":75,"./type":84}],79:[function(require,module,exports){
|
7717 |
|
7718 |
|
7719 |
|
7720 |
|
7721 |
|
7722 |
|
7723 |
|
7724 | 'use strict';
|
7725 |
|
7726 |
|
7727 | var Schema = require('../schema');
|
7728 |
|
7729 |
|
7730 | module.exports = new Schema({
|
7731 | include: [
|
7732 | require('./json')
|
7733 | ]
|
7734 | });
|
7735 |
|
7736 | },{"../schema":78,"./json":83}],80:[function(require,module,exports){
|
7737 |
|
7738 |
|
7739 |
|
7740 |
|
7741 |
|
7742 |
|
7743 |
|
7744 |
|
7745 |
|
7746 | 'use strict';
|
7747 |
|
7748 |
|
7749 | var Schema = require('../schema');
|
7750 |
|
7751 |
|
7752 | module.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 |
|
7765 |
|
7766 |
|
7767 |
|
7768 |
|
7769 |
|
7770 |
|
7771 | 'use strict';
|
7772 |
|
7773 |
|
7774 | var Schema = require('../schema');
|
7775 |
|
7776 |
|
7777 | module.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 |
|
7795 |
|
7796 |
|
7797 |
|
7798 | 'use strict';
|
7799 |
|
7800 |
|
7801 | var Schema = require('../schema');
|
7802 |
|
7803 |
|
7804 | module.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 |
|
7814 |
|
7815 |
|
7816 |
|
7817 |
|
7818 |
|
7819 |
|
7820 |
|
7821 | 'use strict';
|
7822 |
|
7823 |
|
7824 | var Schema = require('../schema');
|
7825 |
|
7826 |
|
7827 | module.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 |
|
7842 | var YAMLException = require('./exception');
|
7843 |
|
7844 | var TYPE_CONSTRUCTOR_OPTIONS = [
|
7845 | 'kind',
|
7846 | 'resolve',
|
7847 | 'construct',
|
7848 | 'instanceOf',
|
7849 | 'predicate',
|
7850 | 'represent',
|
7851 | 'defaultStyle',
|
7852 | 'styleAliases'
|
7853 | ];
|
7854 |
|
7855 | var YAML_NODE_KINDS = [
|
7856 | 'scalar',
|
7857 | 'sequence',
|
7858 | 'mapping'
|
7859 | ];
|
7860 |
|
7861 | function 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 |
|
7875 | function 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 |
|
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 |
|
7900 | module.exports = Type;
|
7901 |
|
7902 | },{"./exception":75}],85:[function(require,module,exports){
|
7903 | 'use strict';
|
7904 |
|
7905 |
|
7906 |
|
7907 | var NodeBuffer;
|
7908 |
|
7909 | try {
|
7910 |
|
7911 | var _require = require;
|
7912 | NodeBuffer = _require('buffer').Buffer;
|
7913 | } catch (__) {}
|
7914 |
|
7915 | var Type = require('../type');
|
7916 |
|
7917 |
|
7918 |
|
7919 | var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
7920 |
|
7921 |
|
7922 | function resolveYamlBinary(data) {
|
7923 | if (data === null) return false;
|
7924 |
|
7925 | var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
7926 |
|
7927 |
|
7928 | for (idx = 0; idx < max; idx++) {
|
7929 | code = map.indexOf(data.charAt(idx));
|
7930 |
|
7931 |
|
7932 | if (code > 64) continue;
|
7933 |
|
7934 |
|
7935 | if (code < 0) return false;
|
7936 |
|
7937 | bitlen += 6;
|
7938 | }
|
7939 |
|
7940 |
|
7941 | return (bitlen % 8) === 0;
|
7942 | }
|
7943 |
|
7944 | function constructYamlBinary(data) {
|
7945 | var idx, tailbits,
|
7946 | input = data.replace(/[\r\n=]/g, ''),
|
7947 | max = input.length,
|
7948 | map = BASE64_MAP,
|
7949 | bits = 0,
|
7950 | result = [];
|
7951 |
|
7952 |
|
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 |
|
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 |
|
7980 | if (NodeBuffer) {
|
7981 |
|
7982 | return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
|
7983 | }
|
7984 |
|
7985 | return result;
|
7986 | }
|
7987 |
|
7988 | function representYamlBinary(object /*, style*/) {
|
7989 | var result = '', bits = 0, idx, tail,
|
7990 | max = object.length,
|
7991 | map = BASE64_MAP;
|
7992 |
|
7993 |
|
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 |
|
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 |
|
8030 | function isBinary(object) {
|
8031 | return NodeBuffer && NodeBuffer.isBuffer(object);
|
8032 | }
|
8033 |
|
8034 | module.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 |
|
8045 | var Type = require('../type');
|
8046 |
|
8047 | function 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 |
|
8056 | function constructYamlBoolean(data) {
|
8057 | return data === 'true' ||
|
8058 | data === 'True' ||
|
8059 | data === 'TRUE';
|
8060 | }
|
8061 |
|
8062 | function isBoolean(object) {
|
8063 | return Object.prototype.toString.call(object) === '[object Boolean]';
|
8064 | }
|
8065 |
|
8066 | module.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 |
|
8082 | var common = require('../common');
|
8083 | var Type = require('../type');
|
8084 |
|
8085 | var YAML_FLOAT_PATTERN = new RegExp(
|
8086 |
|
8087 | '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
|
8088 |
|
8089 |
|
8090 | '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
|
8091 |
|
8092 | '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
|
8093 |
|
8094 | '|[-+]?\\.(?:inf|Inf|INF)' +
|
8095 |
|
8096 | '|\\.(?:nan|NaN|NAN))$');
|
8097 |
|
8098 | function resolveYamlFloat(data) {
|
8099 | if (data === null) return false;
|
8100 |
|
8101 | if (!YAML_FLOAT_PATTERN.test(data) ||
|
8102 |
|
8103 |
|
8104 | data[data.length - 1] === '_') {
|
8105 | return false;
|
8106 | }
|
8107 |
|
8108 | return true;
|
8109 | }
|
8110 |
|
8111 | function 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 |
|
8148 | var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
8149 |
|
8150 | function 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 |
|
8178 |
|
8179 |
|
8180 | return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
|
8181 | }
|
8182 |
|
8183 | function isFloat(object) {
|
8184 | return (Object.prototype.toString.call(object) === '[object Number]') &&
|
8185 | (object % 1 !== 0 || common.isNegativeZero(object));
|
8186 | }
|
8187 |
|
8188 | module.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 |
|
8200 | var common = require('../common');
|
8201 | var Type = require('../type');
|
8202 |
|
8203 | function isHexCode(c) {
|
8204 | return ((0x30 <= c) && (c <= 0x39)) ||
|
8205 | ((0x41 <= c) && (c <= 0x46)) ||
|
8206 | ((0x61 <= c) && (c <= 0x66));
|
8207 | }
|
8208 |
|
8209 | function isOctCode(c) {
|
8210 | return ((0x30 <= c) && (c <= 0x37));
|
8211 | }
|
8212 |
|
8213 | function isDecCode(c) {
|
8214 | return ((0x30 <= c) && (c <= 0x39));
|
8215 | }
|
8216 |
|
8217 | function 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 |
|
8230 | if (ch === '-' || ch === '+') {
|
8231 | ch = data[++index];
|
8232 | }
|
8233 |
|
8234 | if (ch === '0') {
|
8235 |
|
8236 | if (index + 1 === max) return true;
|
8237 | ch = data[++index];
|
8238 |
|
8239 |
|
8240 |
|
8241 | if (ch === 'b') {
|
8242 |
|
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 |
|
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 |
|
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 |
|
8279 |
|
8280 |
|
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 |
|
8294 | if (!hasDigits || ch === '_') return false;
|
8295 |
|
8296 |
|
8297 | if (ch !== ':') return true;
|
8298 |
|
8299 |
|
8300 | return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
8301 | }
|
8302 |
|
8303 | function 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 |
|
8346 | function isInteger(object) {
|
8347 | return (Object.prototype.toString.call(object)) === '[object Number]' &&
|
8348 | (object % 1 === 0 && !common.isNegativeZero(object));
|
8349 | }
|
8350 |
|
8351 | module.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 |
|
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 |
|
8375 | var esprima;
|
8376 |
|
8377 |
|
8378 |
|
8379 |
|
8380 |
|
8381 |
|
8382 |
|
8383 |
|
8384 | try {
|
8385 |
|
8386 | var _require = require;
|
8387 | esprima = _require('esprima');
|
8388 | } catch (_) {
|
8389 |
|
8390 | if (typeof window !== 'undefined') esprima = window.esprima;
|
8391 | }
|
8392 |
|
8393 | var Type = require('../../type');
|
8394 |
|
8395 | function 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 |
|
8416 | function constructJavascriptFunction(data) {
|
8417 |
|
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 |
|
8439 |
|
8440 | if (ast.body[0].expression.body.type === 'BlockStatement') {
|
8441 |
|
8442 | return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
8443 | }
|
8444 |
|
8445 |
|
8446 |
|
8447 | return new Function(params, 'return ' + source.slice(body[0], body[1]));
|
8448 | }
|
8449 |
|
8450 | function representJavascriptFunction(object /*, style*/) {
|
8451 | return object.toString();
|
8452 | }
|
8453 |
|
8454 | function isFunction(object) {
|
8455 | return Object.prototype.toString.call(object) === '[object Function]';
|
8456 | }
|
8457 |
|
8458 | module.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 |
|
8469 | var Type = require('../../type');
|
8470 |
|
8471 | function 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 |
|
8480 |
|
8481 | if (regexp[0] === '/') {
|
8482 | if (tail) modifiers = tail[1];
|
8483 |
|
8484 | if (modifiers.length > 3) return false;
|
8485 |
|
8486 | if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
|
8487 | }
|
8488 |
|
8489 | return true;
|
8490 | }
|
8491 |
|
8492 | function constructJavascriptRegExp(data) {
|
8493 | var regexp = data,
|
8494 | tail = /\/([gim]*)$/.exec(data),
|
8495 | modifiers = '';
|
8496 |
|
8497 |
|
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 |
|
8506 | function 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 |
|
8516 | function isRegExp(object) {
|
8517 | return Object.prototype.toString.call(object) === '[object RegExp]';
|
8518 | }
|
8519 |
|
8520 | module.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 |
|
8531 | var Type = require('../../type');
|
8532 |
|
8533 | function resolveJavascriptUndefined() {
|
8534 | return true;
|
8535 | }
|
8536 |
|
8537 | function constructJavascriptUndefined() {
|
8538 |
|
8539 | return undefined;
|
8540 | }
|
8541 |
|
8542 | function representJavascriptUndefined() {
|
8543 | return '';
|
8544 | }
|
8545 |
|
8546 | function isUndefined(object) {
|
8547 | return typeof object === 'undefined';
|
8548 | }
|
8549 |
|
8550 | module.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 |
|
8561 | var Type = require('../type');
|
8562 |
|
8563 | module.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 |
|
8571 | var Type = require('../type');
|
8572 |
|
8573 | function resolveYamlMerge(data) {
|
8574 | return data === '<<' || data === null;
|
8575 | }
|
8576 |
|
8577 | module.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 |
|
8585 | var Type = require('../type');
|
8586 |
|
8587 | function 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 |
|
8596 | function constructYamlNull() {
|
8597 | return null;
|
8598 | }
|
8599 |
|
8600 | function isNull(object) {
|
8601 | return object === null;
|
8602 | }
|
8603 |
|
8604 | module.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 |
|
8621 | var Type = require('../type');
|
8622 |
|
8623 | var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
8624 | var _toString = Object.prototype.toString;
|
8625 |
|
8626 | function 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 |
|
8654 | function constructYamlOmap(data) {
|
8655 | return data !== null ? data : [];
|
8656 | }
|
8657 |
|
8658 | module.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 |
|
8667 | var Type = require('../type');
|
8668 |
|
8669 | var _toString = Object.prototype.toString;
|
8670 |
|
8671 | function 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 |
|
8694 | function 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 |
|
8713 | module.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 |
|
8722 | var Type = require('../type');
|
8723 |
|
8724 | module.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 |
|
8732 | var Type = require('../type');
|
8733 |
|
8734 | var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
8735 |
|
8736 | function 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 |
|
8750 | function constructYamlSet(data) {
|
8751 | return data !== null ? data : {};
|
8752 | }
|
8753 |
|
8754 | module.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 |
|
8763 | var Type = require('../type');
|
8764 |
|
8765 | module.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 |
|
8773 | var Type = require('../type');
|
8774 |
|
8775 | var YAML_DATE_REGEXP = new RegExp(
|
8776 | '^([0-9][0-9][0-9][0-9])' +
|
8777 | '-([0-9][0-9])' +
|
8778 | '-([0-9][0-9])$');
|
8779 |
|
8780 | var YAML_TIMESTAMP_REGEXP = new RegExp(
|
8781 | '^([0-9][0-9][0-9][0-9])' +
|
8782 | '-([0-9][0-9]?)' +
|
8783 | '-([0-9][0-9]?)' +
|
8784 | '(?:[Tt]|[ \\t]+)' +
|
8785 | '([0-9][0-9]?)' +
|
8786 | ':([0-9][0-9])' +
|
8787 | ':([0-9][0-9])' +
|
8788 | '(?:\\.([0-9]*))?' +
|
8789 | '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' +
|
8790 | '(?::([0-9][0-9]))?))?$');
|
8791 |
|
8792 | function 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 |
|
8799 | function 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 |
|
8809 |
|
8810 | year = +(match[1]);
|
8811 | month = +(match[2]) - 1;
|
8812 | day = +(match[3]);
|
8813 |
|
8814 | if (!match[4]) {
|
8815 | return new Date(Date.UTC(year, month, day));
|
8816 | }
|
8817 |
|
8818 |
|
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) {
|
8827 | fraction += '0';
|
8828 | }
|
8829 | fraction = +fraction;
|
8830 | }
|
8831 |
|
8832 |
|
8833 |
|
8834 | if (match[9]) {
|
8835 | tz_hour = +(match[10]);
|
8836 | tz_minute = +(match[11] || 0);
|
8837 | delta = (tz_hour * 60 + tz_minute) * 60000;
|
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 |
|
8848 | function representYamlTimestamp(object /*, style*/) {
|
8849 | return object.toISOString();
|
8850 | }
|
8851 |
|
8852 | module.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 |
|
8863 | var $Ref = require("./ref"),
|
8864 | Pointer = require("./pointer"),
|
8865 | url = require("./util/url");
|
8866 |
|
8867 | module.exports = bundle;
|
8868 |
|
8869 |
|
8870 |
|
8871 |
|
8872 |
|
8873 |
|
8874 |
|
8875 |
|
8876 |
|
8877 | function bundle (parser, options) {
|
8878 |
|
8879 |
|
8880 |
|
8881 | var inventory = [];
|
8882 | crawl(parser, "schema", parser.$refs._root$Ref.path + "#", "#", 0, inventory, parser.$refs, options);
|
8883 |
|
8884 |
|
8885 | remap(inventory);
|
8886 | }
|
8887 |
|
8888 |
|
8889 |
|
8890 |
|
8891 |
|
8892 |
|
8893 |
|
8894 |
|
8895 |
|
8896 |
|
8897 |
|
8898 |
|
8899 | function 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 |
|
8908 |
|
8909 |
|
8910 | var keys = Object.keys(obj)
|
8911 | .sort(function (a, b) {
|
8912 |
|
8913 |
|
8914 | if (a === "definitions") {
|
8915 | return -1;
|
8916 | }
|
8917 | else if (b === "definitions") {
|
8918 | return 1;
|
8919 | }
|
8920 | else {
|
8921 |
|
8922 |
|
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 |
|
8945 |
|
8946 |
|
8947 |
|
8948 |
|
8949 |
|
8950 |
|
8951 |
|
8952 |
|
8953 |
|
8954 |
|
8955 | function 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 |
|
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,
|
8979 | parent: $refParent,
|
8980 | key: $refKey,
|
8981 | pathFromRoot: pathFromRoot,
|
8982 | depth: depth,
|
8983 | file: file,
|
8984 | hash: hash,
|
8985 | value: pointer.value,
|
8986 | circular: pointer.circular,
|
8987 | extended: extended,
|
8988 | external: external,
|
8989 | indirections: indirections,
|
8990 | });
|
8991 |
|
8992 |
|
8993 | crawl(pointer.value, null, pointer.path, pathFromRoot, indirections + 1, inventory, $refs, options);
|
8994 | }
|
8995 |
|
8996 |
|
8997 |
|
8998 |
|
8999 |
|
9000 |
|
9001 |
|
9002 |
|
9003 |
|
9004 |
|
9005 |
|
9006 |
|
9007 |
|
9008 |
|
9009 |
|
9010 |
|
9011 |
|
9012 |
|
9013 |
|
9014 |
|
9015 |
|
9016 |
|
9017 |
|
9018 |
|
9019 | function remap (inventory) {
|
9020 |
|
9021 | inventory.sort(function (a, b) {
|
9022 | if (a.file !== b.file) {
|
9023 |
|
9024 | return a.file < b.file ? -1 : +1;
|
9025 | }
|
9026 | else if (a.hash !== b.hash) {
|
9027 |
|
9028 | return a.hash < b.hash ? -1 : +1;
|
9029 | }
|
9030 | else if (a.circular !== b.circular) {
|
9031 |
|
9032 | return a.circular ? -1 : +1;
|
9033 | }
|
9034 | else if (a.extended !== b.extended) {
|
9035 |
|
9036 | return a.extended ? +1 : -1;
|
9037 | }
|
9038 | else if (a.indirections !== b.indirections) {
|
9039 |
|
9040 | return a.indirections - b.indirections;
|
9041 | }
|
9042 | else if (a.depth !== b.depth) {
|
9043 |
|
9044 | return a.depth - b.depth;
|
9045 | }
|
9046 | else {
|
9047 |
|
9048 |
|
9049 | var aDefinitionsIndex = a.pathFromRoot.lastIndexOf("/definitions");
|
9050 | var bDefinitionsIndex = b.pathFromRoot.lastIndexOf("/definitions");
|
9051 |
|
9052 | if (aDefinitionsIndex !== bDefinitionsIndex) {
|
9053 |
|
9054 | return bDefinitionsIndex - aDefinitionsIndex;
|
9055 | }
|
9056 | else {
|
9057 |
|
9058 | return a.pathFromRoot.length - b.pathFromRoot.length;
|
9059 | }
|
9060 | }
|
9061 | });
|
9062 |
|
9063 | var file, hash, pathFromRoot;
|
9064 | inventory.forEach(function (entry) {
|
9065 |
|
9066 |
|
9067 | if (!entry.external) {
|
9068 |
|
9069 | entry.$ref.$ref = entry.hash;
|
9070 | }
|
9071 | else if (entry.file === file && entry.hash === hash) {
|
9072 |
|
9073 | entry.$ref.$ref = pathFromRoot;
|
9074 | }
|
9075 | else if (entry.file === file && entry.hash.indexOf(hash + "/") === 0) {
|
9076 |
|
9077 | entry.$ref.$ref = Pointer.join(pathFromRoot, Pointer.parse(entry.hash.replace(hash, "#")));
|
9078 | }
|
9079 | else {
|
9080 |
|
9081 | file = entry.file;
|
9082 | hash = entry.hash;
|
9083 | pathFromRoot = entry.pathFromRoot;
|
9084 |
|
9085 |
|
9086 |
|
9087 | entry.$ref = entry.parent[entry.key] = $Ref.dereference(entry.$ref, entry.value);
|
9088 |
|
9089 | if (entry.circular) {
|
9090 |
|
9091 | entry.$ref.$ref = entry.pathFromRoot;
|
9092 | }
|
9093 | }
|
9094 |
|
9095 |
|
9096 | });
|
9097 | }
|
9098 |
|
9099 |
|
9100 |
|
9101 |
|
9102 | function 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 |
|
9111 | function 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 |
|
9119 | var $Ref = require("./ref"),
|
9120 | Pointer = require("./pointer"),
|
9121 | ono = require("ono"),
|
9122 | url = require("./util/url");
|
9123 |
|
9124 | module.exports = dereference;
|
9125 |
|
9126 |
|
9127 |
|
9128 |
|
9129 |
|
9130 |
|
9131 |
|
9132 |
|
9133 | function dereference (parser, options) {
|
9134 |
|
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 |
|
9142 |
|
9143 |
|
9144 |
|
9145 |
|
9146 |
|
9147 |
|
9148 |
|
9149 |
|
9150 |
|
9151 | function 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 |
|
9190 | result.circular = result.circular || circular;
|
9191 | });
|
9192 | }
|
9193 |
|
9194 | parents.pop();
|
9195 | }
|
9196 |
|
9197 | return result;
|
9198 | }
|
9199 |
|
9200 |
|
9201 |
|
9202 |
|
9203 |
|
9204 |
|
9205 |
|
9206 |
|
9207 |
|
9208 |
|
9209 |
|
9210 |
|
9211 | function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
|
9212 |
|
9213 |
|
9214 | var $refPath = url.resolve(path, $ref.$ref);
|
9215 | var pointer = $refs._resolve($refPath, options);
|
9216 |
|
9217 |
|
9218 | var directCircular = pointer.circular;
|
9219 | var circular = directCircular || parents.indexOf(pointer.value) !== -1;
|
9220 | circular && foundCircularReference(path, $refs, options);
|
9221 |
|
9222 |
|
9223 | var dereferencedValue = $Ref.dereference($ref, pointer.value);
|
9224 |
|
9225 |
|
9226 | if (!circular) {
|
9227 |
|
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 |
|
9235 | dereferencedValue = $ref;
|
9236 | }
|
9237 |
|
9238 | if (directCircular) {
|
9239 |
|
9240 |
|
9241 | dereferencedValue.$ref = pathFromRoot;
|
9242 | }
|
9243 |
|
9244 | return {
|
9245 | circular: circular,
|
9246 | value: dereferencedValue
|
9247 | };
|
9248 | }
|
9249 |
|
9250 |
|
9251 |
|
9252 |
|
9253 |
|
9254 |
|
9255 |
|
9256 |
|
9257 |
|
9258 |
|
9259 | function 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 |
|
9271 | var 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 |
|
9282 | module.exports = $RefParser;
|
9283 | module.exports.YAML = require("./util/yaml");
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 |
|
9289 |
|
9290 |
|
9291 | function $RefParser () {
|
9292 | |
9293 |
|
9294 |
|
9295 |
|
9296 |
|
9297 |
|
9298 | this.schema = null;
|
9299 |
|
9300 | |
9301 |
|
9302 |
|
9303 |
|
9304 |
|
9305 |
|
9306 | this.$refs = new $Refs();
|
9307 | }
|
9308 |
|
9309 |
|
9310 |
|
9311 |
|
9312 |
|
9313 |
|
9314 |
|
9315 |
|
9316 |
|
9317 |
|
9318 |
|
9319 |
|
9320 | $RefParser.parse = function (path, schema, options, callback) {
|
9321 | var Class = this;
|
9322 | var instance = new Class();
|
9323 | return instance.parse.apply(instance, arguments);
|
9324 | };
|
9325 |
|
9326 |
|
9327 |
|
9328 |
|
9329 |
|
9330 |
|
9331 |
|
9332 |
|
9333 |
|
9334 |
|
9335 |
|
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 |
|
9347 | this.schema = null;
|
9348 | this.$refs = new $Refs();
|
9349 |
|
9350 |
|
9351 |
|
9352 |
|
9353 |
|
9354 |
|
9355 |
|
9356 | var pathType = "http";
|
9357 | if (url.isFileSystemPath(args.path)) {
|
9358 | args.path = url.fromFileSystemPath(args.path);
|
9359 | pathType = "file";
|
9360 | }
|
9361 |
|
9362 |
|
9363 | args.path = url.resolve(url.cwd(), args.path);
|
9364 |
|
9365 | if (args.schema && typeof args.schema === "object") {
|
9366 |
|
9367 |
|
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 |
|
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 |
|
9396 |
|
9397 |
|
9398 |
|
9399 |
|
9400 |
|
9401 |
|
9402 |
|
9403 |
|
9404 |
|
9405 |
|
9406 |
|
9407 | $RefParser.resolve = function (path, schema, options, callback) {
|
9408 | var Class = this;
|
9409 | var instance = new Class();
|
9410 | return instance.resolve.apply(instance, arguments);
|
9411 | };
|
9412 |
|
9413 |
|
9414 |
|
9415 |
|
9416 |
|
9417 |
|
9418 |
|
9419 |
|
9420 |
|
9421 |
|
9422 |
|
9423 |
|
9424 |
|
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 |
|
9444 |
|
9445 |
|
9446 |
|
9447 |
|
9448 |
|
9449 |
|
9450 |
|
9451 |
|
9452 |
|
9453 | $RefParser.bundle = function (path, schema, options, callback) {
|
9454 | var Class = this;
|
9455 | var instance = new Class();
|
9456 | return instance.bundle.apply(instance, arguments);
|
9457 | };
|
9458 |
|
9459 |
|
9460 |
|
9461 |
|
9462 |
|
9463 |
|
9464 |
|
9465 |
|
9466 |
|
9467 |
|
9468 |
|
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 |
|
9486 |
|
9487 |
|
9488 |
|
9489 |
|
9490 |
|
9491 |
|
9492 |
|
9493 |
|
9494 | $RefParser.dereference = function (path, schema, options, callback) {
|
9495 | var Class = this;
|
9496 | var instance = new Class();
|
9497 | return instance.dereference.apply(instance, arguments);
|
9498 | };
|
9499 |
|
9500 |
|
9501 |
|
9502 |
|
9503 |
|
9504 |
|
9505 |
|
9506 |
|
9507 |
|
9508 |
|
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 |
|
9529 | var Options = require("./options");
|
9530 |
|
9531 | module.exports = normalizeArgs;
|
9532 |
|
9533 |
|
9534 |
|
9535 |
|
9536 |
|
9537 |
|
9538 |
|
9539 | function 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 |
|
9545 | callback = args.pop();
|
9546 | }
|
9547 |
|
9548 | if (typeof args[0] === "string") {
|
9549 |
|
9550 | path = args[0];
|
9551 | if (typeof args[2] === "object") {
|
9552 |
|
9553 | schema = args[1];
|
9554 | options = args[2];
|
9555 | }
|
9556 | else {
|
9557 |
|
9558 | schema = undefined;
|
9559 | options = args[1];
|
9560 | }
|
9561 | }
|
9562 | else {
|
9563 |
|
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 |
|
9583 | "use strict";
|
9584 |
|
9585 | var 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 |
|
9592 | module.exports = $RefParserOptions;
|
9593 |
|
9594 |
|
9595 |
|
9596 |
|
9597 |
|
9598 |
|
9599 |
|
9600 | function $RefParserOptions (options) {
|
9601 | merge(this, $RefParserOptions.defaults);
|
9602 | merge(this, options);
|
9603 | }
|
9604 |
|
9605 | $RefParserOptions.defaults = {
|
9606 | |
9607 |
|
9608 |
|
9609 |
|
9610 |
|
9611 |
|
9612 | parse: {
|
9613 | json: jsonParser,
|
9614 | yaml: yamlParser,
|
9615 | text: textParser,
|
9616 | binary: binaryParser,
|
9617 | },
|
9618 |
|
9619 | |
9620 |
|
9621 |
|
9622 |
|
9623 |
|
9624 |
|
9625 | resolve: {
|
9626 | file: fileResolver,
|
9627 | http: httpResolver,
|
9628 |
|
9629 | |
9630 |
|
9631 |
|
9632 |
|
9633 |
|
9634 |
|
9635 |
|
9636 | external: true,
|
9637 | },
|
9638 |
|
9639 | |
9640 |
|
9641 |
|
9642 | dereference: {
|
9643 | |
9644 |
|
9645 |
|
9646 |
|
9647 |
|
9648 |
|
9649 |
|
9650 | circular: true
|
9651 | },
|
9652 | };
|
9653 |
|
9654 |
|
9655 |
|
9656 |
|
9657 |
|
9658 |
|
9659 |
|
9660 |
|
9661 | function 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 |
|
9671 | target[key] = merge(targetSetting || {}, sourceSetting);
|
9672 | }
|
9673 | else if (sourceSetting !== undefined) {
|
9674 |
|
9675 | target[key] = sourceSetting;
|
9676 | }
|
9677 | }
|
9678 | }
|
9679 | return target;
|
9680 | }
|
9681 |
|
9682 |
|
9683 |
|
9684 |
|
9685 |
|
9686 |
|
9687 |
|
9688 |
|
9689 | function 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 |
|
9701 | var ono = require("ono"),
|
9702 | url = require("./util/url"),
|
9703 | plugins = require("./util/plugins");
|
9704 |
|
9705 | module.exports = parse;
|
9706 |
|
9707 |
|
9708 |
|
9709 |
|
9710 |
|
9711 |
|
9712 |
|
9713 |
|
9714 |
|
9715 |
|
9716 |
|
9717 | function parse (path, $refs, options) {
|
9718 | try {
|
9719 |
|
9720 | path = url.stripHash(path);
|
9721 |
|
9722 |
|
9723 |
|
9724 | var $ref = $refs._add(path);
|
9725 |
|
9726 |
|
9727 | var file = {
|
9728 | url: path,
|
9729 | extension: url.getExtension(path),
|
9730 | };
|
9731 |
|
9732 |
|
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 |
|
9751 |
|
9752 |
|
9753 |
|
9754 |
|
9755 |
|
9756 |
|
9757 |
|
9758 |
|
9759 |
|
9760 | function readFile (file, options) {
|
9761 | return new Promise(function (resolve, reject) {
|
9762 |
|
9763 |
|
9764 |
|
9765 | var resolvers = plugins.all(options.resolve);
|
9766 | resolvers = plugins.filter(resolvers, "canRead", file);
|
9767 |
|
9768 |
|
9769 | plugins.sort(resolvers);
|
9770 | plugins.run(resolvers, "read", file)
|
9771 | .then(resolve, onError);
|
9772 |
|
9773 | function onError (err) {
|
9774 |
|
9775 |
|
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 |
|
9788 |
|
9789 |
|
9790 |
|
9791 |
|
9792 |
|
9793 |
|
9794 |
|
9795 |
|
9796 |
|
9797 |
|
9798 | function parseFile (file, options) {
|
9799 | return new Promise(function (resolve, reject) {
|
9800 |
|
9801 |
|
9802 |
|
9803 |
|
9804 |
|
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 |
|
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 |
|
9837 |
|
9838 |
|
9839 |
|
9840 |
|
9841 | function 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 |
|
9854 | var BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
|
9855 |
|
9856 | module.exports = {
|
9857 | |
9858 |
|
9859 |
|
9860 |
|
9861 |
|
9862 | order: 400,
|
9863 |
|
9864 | |
9865 |
|
9866 |
|
9867 |
|
9868 |
|
9869 | allowEmpty: true,
|
9870 |
|
9871 | |
9872 |
|
9873 |
|
9874 |
|
9875 |
|
9876 |
|
9877 |
|
9878 |
|
9879 |
|
9880 |
|
9881 |
|
9882 |
|
9883 | canParse: function isBinary (file) {
|
9884 |
|
9885 | return Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url);
|
9886 | },
|
9887 |
|
9888 | |
9889 |
|
9890 |
|
9891 |
|
9892 |
|
9893 |
|
9894 |
|
9895 |
|
9896 |
|
9897 | parse: function parseBinary (file) {
|
9898 | if (Buffer.isBuffer(file.data)) {
|
9899 | return file.data;
|
9900 | }
|
9901 | else {
|
9902 |
|
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 |
|
9914 | module.exports = {
|
9915 | |
9916 |
|
9917 |
|
9918 |
|
9919 |
|
9920 | order: 100,
|
9921 |
|
9922 | |
9923 |
|
9924 |
|
9925 |
|
9926 |
|
9927 | allowEmpty: true,
|
9928 |
|
9929 | |
9930 |
|
9931 |
|
9932 |
|
9933 |
|
9934 |
|
9935 |
|
9936 |
|
9937 | canParse: ".json",
|
9938 |
|
9939 | |
9940 |
|
9941 |
|
9942 |
|
9943 |
|
9944 |
|
9945 |
|
9946 |
|
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);
|
9958 | }
|
9959 | else {
|
9960 | resolve(JSON.parse(data));
|
9961 | }
|
9962 | }
|
9963 | else {
|
9964 |
|
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 |
|
9977 | var TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
|
9978 |
|
9979 | module.exports = {
|
9980 | |
9981 |
|
9982 |
|
9983 |
|
9984 |
|
9985 | order: 300,
|
9986 |
|
9987 | |
9988 |
|
9989 |
|
9990 |
|
9991 |
|
9992 | allowEmpty: true,
|
9993 |
|
9994 | |
9995 |
|
9996 |
|
9997 |
|
9998 |
|
9999 | encoding: "utf8",
|
10000 |
|
10001 | |
10002 |
|
10003 |
|
10004 |
|
10005 |
|
10006 |
|
10007 |
|
10008 |
|
10009 |
|
10010 |
|
10011 |
|
10012 |
|
10013 | canParse: function isText (file) {
|
10014 |
|
10015 | return (typeof file.data === "string" || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url);
|
10016 | },
|
10017 |
|
10018 | |
10019 |
|
10020 |
|
10021 |
|
10022 |
|
10023 |
|
10024 |
|
10025 |
|
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 |
|
10046 | var YAML = require("../util/yaml");
|
10047 |
|
10048 | module.exports = {
|
10049 | |
10050 |
|
10051 |
|
10052 |
|
10053 |
|
10054 | order: 200,
|
10055 |
|
10056 | |
10057 |
|
10058 |
|
10059 |
|
10060 |
|
10061 | allowEmpty: true,
|
10062 |
|
10063 | |
10064 |
|
10065 |
|
10066 |
|
10067 |
|
10068 |
|
10069 |
|
10070 |
|
10071 | canParse: [".yaml", ".yml", ".json"],
|
10072 |
|
10073 | |
10074 |
|
10075 |
|
10076 |
|
10077 |
|
10078 |
|
10079 |
|
10080 |
|
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 |
|
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 |
|
10105 | module.exports = Pointer;
|
10106 |
|
10107 | var $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 |
|
10117 |
|
10118 |
|
10119 |
|
10120 |
|
10121 |
|
10122 |
|
10123 | function Pointer ($ref, path, friendlyPath) {
|
10124 | |
10125 |
|
10126 |
|
10127 |
|
10128 | this.$ref = $ref;
|
10129 |
|
10130 | |
10131 |
|
10132 |
|
10133 |
|
10134 |
|
10135 | this.path = path;
|
10136 |
|
10137 | |
10138 |
|
10139 |
|
10140 |
|
10141 | this.originalPath = friendlyPath || path;
|
10142 |
|
10143 | |
10144 |
|
10145 |
|
10146 |
|
10147 |
|
10148 | this.value = undefined;
|
10149 |
|
10150 | |
10151 |
|
10152 |
|
10153 |
|
10154 | this.circular = false;
|
10155 |
|
10156 | |
10157 |
|
10158 |
|
10159 |
|
10160 |
|
10161 | this.indirections = 0;
|
10162 | }
|
10163 |
|
10164 |
|
10165 |
|
10166 |
|
10167 |
|
10168 |
|
10169 |
|
10170 |
|
10171 |
|
10172 |
|
10173 |
|
10174 |
|
10175 |
|
10176 | Pointer.prototype.resolve = function (obj, options) {
|
10177 | var tokens = Pointer.parse(this.path);
|
10178 |
|
10179 |
|
10180 | this.value = obj;
|
10181 | for (var i = 0; i < tokens.length; i++) {
|
10182 | if (resolveIf$Ref(this, options)) {
|
10183 |
|
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 |
|
10197 | resolveIf$Ref(this, options);
|
10198 | return this;
|
10199 | };
|
10200 |
|
10201 |
|
10202 |
|
10203 |
|
10204 |
|
10205 |
|
10206 |
|
10207 |
|
10208 |
|
10209 |
|
10210 |
|
10211 | Pointer.prototype.set = function (obj, value, options) {
|
10212 | var tokens = Pointer.parse(this.path);
|
10213 | var token;
|
10214 |
|
10215 | if (tokens.length === 0) {
|
10216 |
|
10217 | this.value = value;
|
10218 | return value;
|
10219 | }
|
10220 |
|
10221 |
|
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 |
|
10229 | this.value = this.value[token];
|
10230 | }
|
10231 | else {
|
10232 |
|
10233 | this.value = setValue(this, token, {});
|
10234 | }
|
10235 | }
|
10236 |
|
10237 |
|
10238 | resolveIf$Ref(this, options);
|
10239 | token = tokens[tokens.length - 1];
|
10240 | setValue(this, token, value);
|
10241 |
|
10242 |
|
10243 | return obj;
|
10244 | };
|
10245 |
|
10246 |
|
10247 |
|
10248 |
|
10249 |
|
10250 |
|
10251 |
|
10252 |
|
10253 |
|
10254 |
|
10255 |
|
10256 |
|
10257 | Pointer.parse = function (path) {
|
10258 |
|
10259 | var pointer = url.getHash(path).substr(1);
|
10260 |
|
10261 |
|
10262 |
|
10263 | if (!pointer) {
|
10264 | return [];
|
10265 | }
|
10266 |
|
10267 |
|
10268 | pointer = pointer.split("/");
|
10269 |
|
10270 |
|
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 |
|
10284 |
|
10285 |
|
10286 |
|
10287 |
|
10288 |
|
10289 | Pointer.join = function (base, tokens) {
|
10290 |
|
10291 | if (base.indexOf("#") === -1) {
|
10292 | base += "#";
|
10293 | }
|
10294 |
|
10295 |
|
10296 | tokens = Array.isArray(tokens) ? tokens : [tokens];
|
10297 | for (var i = 0; i < tokens.length; i++) {
|
10298 | var token = tokens[i];
|
10299 |
|
10300 | base += "/" + encodeURIComponent(token.replace(tildes, "~0").replace(slashes, "~1"));
|
10301 | }
|
10302 |
|
10303 | return base;
|
10304 | };
|
10305 |
|
10306 |
|
10307 |
|
10308 |
|
10309 |
|
10310 |
|
10311 |
|
10312 |
|
10313 |
|
10314 |
|
10315 |
|
10316 | function resolveIf$Ref (pointer, options) {
|
10317 |
|
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 |
|
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 |
|
10332 |
|
10333 | pointer.value = $Ref.dereference(pointer.value, resolved.value);
|
10334 | return false;
|
10335 | }
|
10336 | else {
|
10337 |
|
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 |
|
10350 |
|
10351 |
|
10352 |
|
10353 |
|
10354 |
|
10355 |
|
10356 |
|
10357 |
|
10358 |
|
10359 | function 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 |
|
10377 | module.exports = $Ref;
|
10378 |
|
10379 | var Pointer = require("./pointer");
|
10380 |
|
10381 |
|
10382 |
|
10383 |
|
10384 |
|
10385 |
|
10386 | function $Ref () {
|
10387 | |
10388 |
|
10389 |
|
10390 |
|
10391 |
|
10392 |
|
10393 |
|
10394 |
|
10395 |
|
10396 |
|
10397 | this.path = undefined;
|
10398 |
|
10399 | |
10400 |
|
10401 |
|
10402 |
|
10403 |
|
10404 | this.value = undefined;
|
10405 |
|
10406 | |
10407 |
|
10408 |
|
10409 |
|
10410 | this.$refs = undefined;
|
10411 |
|
10412 | |
10413 |
|
10414 |
|
10415 |
|
10416 | this.pathType = undefined;
|
10417 | }
|
10418 |
|
10419 |
|
10420 |
|
10421 |
|
10422 |
|
10423 |
|
10424 |
|
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 |
|
10438 |
|
10439 |
|
10440 |
|
10441 |
|
10442 |
|
10443 | $Ref.prototype.get = function (path, options) {
|
10444 | return this.resolve(path, options).value;
|
10445 | };
|
10446 |
|
10447 |
|
10448 |
|
10449 |
|
10450 |
|
10451 |
|
10452 |
|
10453 |
|
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 |
|
10462 |
|
10463 |
|
10464 |
|
10465 |
|
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 |
|
10474 |
|
10475 |
|
10476 |
|
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 |
|
10484 |
|
10485 |
|
10486 |
|
10487 |
|
10488 | $Ref.isExternal$Ref = function (value) {
|
10489 | return $Ref.is$Ref(value) && value.$ref[0] !== "#";
|
10490 | };
|
10491 |
|
10492 |
|
10493 |
|
10494 |
|
10495 |
|
10496 |
|
10497 |
|
10498 |
|
10499 |
|
10500 | $Ref.isAllowed$Ref = function (value, options) {
|
10501 | if ($Ref.is$Ref(value)) {
|
10502 | if (value.$ref.substr(0, 2) === "#/" || value.$ref === "#") {
|
10503 |
|
10504 | return true;
|
10505 | }
|
10506 | else if (value.$ref[0] !== "#" && (!options || options.resolve.external)) {
|
10507 |
|
10508 | return true;
|
10509 | }
|
10510 | }
|
10511 | };
|
10512 |
|
10513 |
|
10514 |
|
10515 |
|
10516 |
|
10517 |
|
10518 |
|
10519 |
|
10520 |
|
10521 |
|
10522 |
|
10523 |
|
10524 |
|
10525 |
|
10526 |
|
10527 |
|
10528 |
|
10529 |
|
10530 |
|
10531 |
|
10532 |
|
10533 |
|
10534 |
|
10535 |
|
10536 |
|
10537 |
|
10538 |
|
10539 |
|
10540 |
|
10541 |
|
10542 |
|
10543 |
|
10544 |
|
10545 |
|
10546 |
|
10547 |
|
10548 |
|
10549 | $Ref.isExtended$Ref = function (value) {
|
10550 | return $Ref.is$Ref(value) && Object.keys(value).length > 1;
|
10551 | };
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 |
|
10558 |
|
10559 |
|
10560 |
|
10561 |
|
10562 |
|
10563 |
|
10564 |
|
10565 |
|
10566 |
|
10567 |
|
10568 |
|
10569 |
|
10570 |
|
10571 |
|
10572 |
|
10573 |
|
10574 |
|
10575 |
|
10576 |
|
10577 |
|
10578 |
|
10579 |
|
10580 |
|
10581 |
|
10582 |
|
10583 |
|
10584 |
|
10585 |
|
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 |
|
10604 | return resolvedValue;
|
10605 | }
|
10606 | };
|
10607 |
|
10608 | },{"./pointer":111}],113:[function(require,module,exports){
|
10609 | "use strict";
|
10610 |
|
10611 | var ono = require("ono"),
|
10612 | $Ref = require("./ref"),
|
10613 | url = require("./util/url");
|
10614 |
|
10615 | module.exports = $Refs;
|
10616 |
|
10617 |
|
10618 |
|
10619 |
|
10620 | function $Refs () {
|
10621 | |
10622 |
|
10623 |
|
10624 |
|
10625 |
|
10626 | this.circular = false;
|
10627 |
|
10628 | |
10629 |
|
10630 |
|
10631 |
|
10632 |
|
10633 |
|
10634 | this._$refs = {};
|
10635 |
|
10636 | |
10637 |
|
10638 |
|
10639 |
|
10640 |
|
10641 |
|
10642 | this._root$Ref = null;
|
10643 | }
|
10644 |
|
10645 |
|
10646 |
|
10647 |
|
10648 |
|
10649 |
|
10650 |
|
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 |
|
10661 |
|
10662 |
|
10663 |
|
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 |
|
10676 |
|
10677 |
|
10678 |
|
10679 | $Refs.prototype.toJSON = $Refs.prototype.values;
|
10680 |
|
10681 |
|
10682 |
|
10683 |
|
10684 |
|
10685 |
|
10686 |
|
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 |
|
10700 |
|
10701 |
|
10702 |
|
10703 |
|
10704 |
|
10705 | $Refs.prototype.get = function (path, options) {
|
10706 | return this._resolve(path, options).value;
|
10707 | };
|
10708 |
|
10709 |
|
10710 |
|
10711 |
|
10712 |
|
10713 |
|
10714 |
|
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 |
|
10730 |
|
10731 |
|
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 |
|
10748 |
|
10749 |
|
10750 |
|
10751 |
|
10752 |
|
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 |
|
10768 |
|
10769 |
|
10770 |
|
10771 |
|
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 |
|
10781 |
|
10782 |
|
10783 |
|
10784 |
|
10785 |
|
10786 | function getPaths ($refs, types) {
|
10787 | var paths = Object.keys($refs);
|
10788 |
|
10789 |
|
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 |
|
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 |
|
10809 | var $Ref = require("./ref"),
|
10810 | Pointer = require("./pointer"),
|
10811 | parse = require("./parse"),
|
10812 | url = require("./util/url");
|
10813 |
|
10814 | module.exports = resolveExternal;
|
10815 |
|
10816 |
|
10817 |
|
10818 |
|
10819 |
|
10820 |
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 |
|
10826 |
|
10827 |
|
10828 |
|
10829 | function resolveExternal (parser, options) {
|
10830 | if (!options.resolve.external) {
|
10831 |
|
10832 | return Promise.resolve();
|
10833 | }
|
10834 |
|
10835 | try {
|
10836 |
|
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 |
|
10847 |
|
10848 |
|
10849 |
|
10850 |
|
10851 |
|
10852 |
|
10853 |
|
10854 |
|
10855 |
|
10856 |
|
10857 |
|
10858 |
|
10859 | function 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 |
|
10886 |
|
10887 |
|
10888 |
|
10889 |
|
10890 |
|
10891 |
|
10892 |
|
10893 |
|
10894 |
|
10895 |
|
10896 | function resolve$Ref ($ref, path, $refs, options) {
|
10897 |
|
10898 |
|
10899 | var resolvedPath = url.resolve(path, $ref.$ref);
|
10900 | var withoutHash = url.stripHash(resolvedPath);
|
10901 |
|
10902 |
|
10903 | $ref = $refs._$refs[withoutHash];
|
10904 | if ($ref) {
|
10905 |
|
10906 | return Promise.resolve($ref.value);
|
10907 | }
|
10908 |
|
10909 |
|
10910 | return parse(resolvedPath, $refs, options)
|
10911 | .then(function (result) {
|
10912 |
|
10913 |
|
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";
|
10921 | var fs = require("fs"),
|
10922 | ono = require("ono"),
|
10923 | url = require("../util/url");
|
10924 |
|
10925 | module.exports = {
|
10926 | |
10927 |
|
10928 |
|
10929 |
|
10930 |
|
10931 | order: 100,
|
10932 |
|
10933 | |
10934 |
|
10935 |
|
10936 |
|
10937 |
|
10938 |
|
10939 |
|
10940 |
|
10941 |
|
10942 |
|
10943 | canRead: function isFile (file) {
|
10944 | return url.isFileSystemPath(file.url);
|
10945 | },
|
10946 |
|
10947 | |
10948 |
|
10949 |
|
10950 |
|
10951 |
|
10952 |
|
10953 |
|
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 |
|
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 |
|
10988 | var http = require("http"),
|
10989 | https = require("https"),
|
10990 | ono = require("ono"),
|
10991 | url = require("../util/url");
|
10992 |
|
10993 | module.exports = {
|
10994 | |
10995 |
|
10996 |
|
10997 |
|
10998 |
|
10999 | order: 200,
|
11000 |
|
11001 | |
11002 |
|
11003 |
|
11004 |
|
11005 |
|
11006 |
|
11007 |
|
11008 |
|
11009 |
|
11010 |
|
11011 |
|
11012 | headers: null,
|
11013 |
|
11014 | |
11015 |
|
11016 |
|
11017 |
|
11018 |
|
11019 | timeout: 5000,
|
11020 |
|
11021 | |
11022 |
|
11023 |
|
11024 |
|
11025 |
|
11026 |
|
11027 | redirects: 5,
|
11028 |
|
11029 | |
11030 |
|
11031 |
|
11032 |
|
11033 |
|
11034 |
|
11035 | withCredentials: false,
|
11036 |
|
11037 | |
11038 |
|
11039 |
|
11040 |
|
11041 |
|
11042 |
|
11043 |
|
11044 |
|
11045 |
|
11046 |
|
11047 | canRead: function isHttp (file) {
|
11048 | return url.isHttp(file.url);
|
11049 | },
|
11050 |
|
11051 | |
11052 |
|
11053 |
|
11054 |
|
11055 |
|
11056 |
|
11057 |
|
11058 |
|
11059 | read: function readHttp (file) {
|
11060 | var u = url.parse(file.url);
|
11061 |
|
11062 | if (process.browser && !u.protocol) {
|
11063 |
|
11064 | u.protocol = url.parse(location.href).protocol;
|
11065 | }
|
11066 |
|
11067 | return download(u, this);
|
11068 | }
|
11069 | };
|
11070 |
|
11071 |
|
11072 |
|
11073 |
|
11074 |
|
11075 |
|
11076 |
|
11077 |
|
11078 |
|
11079 |
|
11080 |
|
11081 | function 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 |
|
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 |
|
11118 |
|
11119 |
|
11120 |
|
11121 |
|
11122 |
|
11123 |
|
11124 |
|
11125 | function get (u, httpOptions) {
|
11126 | return new Promise(function (resolve, reject) {
|
11127 |
|
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 |
|
11173 |
|
11174 |
|
11175 |
|
11176 |
|
11177 |
|
11178 | exports.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 |
|
11191 |
|
11192 |
|
11193 |
|
11194 |
|
11195 |
|
11196 |
|
11197 | exports.filter = function (plugins, method, file) {
|
11198 | return plugins
|
11199 | .filter(function (plugin) {
|
11200 | return !!getResult(plugin, method, file);
|
11201 | });
|
11202 | };
|
11203 |
|
11204 |
|
11205 |
|
11206 |
|
11207 |
|
11208 |
|
11209 |
|
11210 | exports.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 |
|
11220 |
|
11221 |
|
11222 |
|
11223 |
|
11224 |
|
11225 |
|
11226 |
|
11227 |
|
11228 |
|
11229 |
|
11230 |
|
11231 | exports.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 |
|
11241 | return reject(lastError);
|
11242 | }
|
11243 |
|
11244 | try {
|
11245 |
|
11246 | var result = getResult(plugin, method, file, callback);
|
11247 | if (result && typeof result.then === "function") {
|
11248 |
|
11249 | result.then(onSuccess, onError);
|
11250 | }
|
11251 | else if (result !== undefined) {
|
11252 |
|
11253 | onSuccess(result);
|
11254 | }
|
11255 |
|
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 |
|
11273 | resolve({
|
11274 | plugin: plugin,
|
11275 | result: result
|
11276 | });
|
11277 | }
|
11278 |
|
11279 | function onError (err) {
|
11280 |
|
11281 | lastError = err;
|
11282 | runNextPlugin();
|
11283 | }
|
11284 | });
|
11285 | };
|
11286 |
|
11287 |
|
11288 |
|
11289 |
|
11290 |
|
11291 |
|
11292 |
|
11293 |
|
11294 |
|
11295 |
|
11296 |
|
11297 |
|
11298 |
|
11299 | function 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 |
|
11308 |
|
11309 |
|
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 |
|
11328 | var isWindows = /^win/.test(process.platform),
|
11329 | forwardSlashPattern = /\//g,
|
11330 | protocolPattern = /^(\w{2,}):\/\//i,
|
11331 | url = module.exports;
|
11332 |
|
11333 |
|
11334 | var urlEncodePatterns = [
|
11335 | /\?/g, "%3F",
|
11336 | /\#/g, "%23",
|
11337 | ];
|
11338 |
|
11339 |
|
11340 | var urlDecodePatterns = [
|
11341 | /\%23/g, "#",
|
11342 | /\%24/g, "$",
|
11343 | /\%26/g, "&",
|
11344 | /\%2C/g, ",",
|
11345 | /\%40/g, "@"
|
11346 | ];
|
11347 |
|
11348 | exports.parse = require("url").parse;
|
11349 | exports.resolve = require("url").resolve;
|
11350 |
|
11351 |
|
11352 |
|
11353 |
|
11354 |
|
11355 |
|
11356 | exports.cwd = function cwd () {
|
11357 | return process.browser ? location.href : process.cwd() + "/";
|
11358 | };
|
11359 |
|
11360 |
|
11361 |
|
11362 |
|
11363 |
|
11364 |
|
11365 |
|
11366 | exports.getProtocol = function getProtocol (path) {
|
11367 | var match = protocolPattern.exec(path);
|
11368 | if (match) {
|
11369 | return match[1].toLowerCase();
|
11370 | }
|
11371 | };
|
11372 |
|
11373 |
|
11374 |
|
11375 |
|
11376 |
|
11377 |
|
11378 |
|
11379 |
|
11380 | exports.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 |
|
11390 |
|
11391 |
|
11392 |
|
11393 |
|
11394 |
|
11395 | exports.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 |
|
11405 |
|
11406 |
|
11407 |
|
11408 |
|
11409 | exports.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 |
|
11419 |
|
11420 |
|
11421 |
|
11422 |
|
11423 | exports.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 |
|
11430 | return process.browser;
|
11431 | }
|
11432 | else {
|
11433 |
|
11434 | return false;
|
11435 | }
|
11436 | };
|
11437 |
|
11438 |
|
11439 |
|
11440 |
|
11441 |
|
11442 |
|
11443 |
|
11444 |
|
11445 | exports.isFileSystemPath = function isFileSystemPath (path) {
|
11446 | if (process.browser) {
|
11447 |
|
11448 |
|
11449 | return false;
|
11450 | }
|
11451 |
|
11452 | var protocol = url.getProtocol(path);
|
11453 | return protocol === undefined || protocol === "file";
|
11454 | };
|
11455 |
|
11456 |
|
11457 |
|
11458 |
|
11459 |
|
11460 |
|
11461 |
|
11462 |
|
11463 |
|
11464 |
|
11465 |
|
11466 |
|
11467 |
|
11468 |
|
11469 |
|
11470 |
|
11471 |
|
11472 | exports.fromFileSystemPath = function fromFileSystemPath (path) {
|
11473 |
|
11474 |
|
11475 | if (isWindows) {
|
11476 | path = path.replace(/\\/g, "/");
|
11477 | }
|
11478 |
|
11479 |
|
11480 | path = encodeURI(path);
|
11481 |
|
11482 |
|
11483 |
|
11484 |
|
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 |
|
11494 |
|
11495 |
|
11496 |
|
11497 |
|
11498 |
|
11499 | exports.toFileSystemPath = function toFileSystemPath (path, keepFileProtocol) {
|
11500 |
|
11501 | path = decodeURI(path);
|
11502 |
|
11503 |
|
11504 |
|
11505 |
|
11506 | for (var i = 0; i < urlDecodePatterns.length; i += 2) {
|
11507 | path = path.replace(urlDecodePatterns[i], urlDecodePatterns[i + 1]);
|
11508 | }
|
11509 |
|
11510 |
|
11511 |
|
11512 | var isFileUrl = path.substr(0, 7).toLowerCase() === "file://";
|
11513 | if (isFileUrl) {
|
11514 |
|
11515 | path = path[7] === "/" ? path.substr(8) : path.substr(7);
|
11516 |
|
11517 |
|
11518 | if (isWindows && path[1] === "/") {
|
11519 | path = path[0] + ":" + path.substr(1);
|
11520 | }
|
11521 |
|
11522 | if (keepFileProtocol) {
|
11523 |
|
11524 | path = "file:///" + path;
|
11525 | }
|
11526 | else {
|
11527 |
|
11528 |
|
11529 |
|
11530 | isFileUrl = false;
|
11531 | path = isWindows ? path : "/" + path;
|
11532 | }
|
11533 | }
|
11534 |
|
11535 |
|
11536 | if (isWindows && !isFileUrl) {
|
11537 |
|
11538 | path = path.replace(forwardSlashPattern, "\\");
|
11539 |
|
11540 |
|
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 |
|
11553 | "use strict";
|
11554 |
|
11555 | var yaml = require("js-yaml"),
|
11556 | ono = require("ono");
|
11557 |
|
11558 |
|
11559 |
|
11560 |
|
11561 | module.exports = {
|
11562 | |
11563 |
|
11564 |
|
11565 |
|
11566 |
|
11567 |
|
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 |
|
11579 | throw ono(e, e.message);
|
11580 | }
|
11581 | }
|
11582 | },
|
11583 |
|
11584 | |
11585 |
|
11586 |
|
11587 |
|
11588 |
|
11589 |
|
11590 |
|
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 |
|
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 |
|
11613 |
|
11614 |
|
11615 |
|
11616 |
|
11617 |
|
11618 |
|
11619 |
|
11620 |
|
11621 | var FUNC_ERROR_TEXT = 'Expected a function';
|
11622 |
|
11623 |
|
11624 | var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
11625 |
|
11626 |
|
11627 | var INFINITY = 1 / 0;
|
11628 |
|
11629 |
|
11630 | var funcTag = '[object Function]',
|
11631 | genTag = '[object GeneratorFunction]',
|
11632 | symbolTag = '[object Symbol]';
|
11633 |
|
11634 |
|
11635 | var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
11636 | reIsPlainProp = /^\w*$/,
|
11637 | reLeadingDot = /^\./,
|
11638 | rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
11639 |
|
11640 |
|
11641 |
|
11642 |
|
11643 |
|
11644 | var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
11645 |
|
11646 |
|
11647 | var reEscapeChar = /\\(\\)?/g;
|
11648 |
|
11649 |
|
11650 | var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
11651 |
|
11652 |
|
11653 | var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
11654 |
|
11655 |
|
11656 | var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
11657 |
|
11658 |
|
11659 | var root = freeGlobal || freeSelf || Function('return this')();
|
11660 |
|
11661 |
|
11662 |
|
11663 |
|
11664 |
|
11665 |
|
11666 |
|
11667 |
|
11668 |
|
11669 | function getValue(object, key) {
|
11670 | return object == null ? undefined : object[key];
|
11671 | }
|
11672 |
|
11673 |
|
11674 |
|
11675 |
|
11676 |
|
11677 |
|
11678 |
|
11679 |
|
11680 | function isHostObject(value) {
|
11681 |
|
11682 |
|
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 |
|
11693 | var arrayProto = Array.prototype,
|
11694 | funcProto = Function.prototype,
|
11695 | objectProto = Object.prototype;
|
11696 |
|
11697 |
|
11698 | var coreJsData = root['__core-js_shared__'];
|
11699 |
|
11700 |
|
11701 | var maskSrcKey = (function() {
|
11702 | var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
11703 | return uid ? ('Symbol(src)_1.' + uid) : '';
|
11704 | }());
|
11705 |
|
11706 |
|
11707 | var funcToString = funcProto.toString;
|
11708 |
|
11709 |
|
11710 | var hasOwnProperty = objectProto.hasOwnProperty;
|
11711 |
|
11712 |
|
11713 |
|
11714 |
|
11715 |
|
11716 |
|
11717 | var objectToString = objectProto.toString;
|
11718 |
|
11719 |
|
11720 | var reIsNative = RegExp('^' +
|
11721 | funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
11722 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
11723 | );
|
11724 |
|
11725 |
|
11726 | var Symbol = root.Symbol,
|
11727 | splice = arrayProto.splice;
|
11728 |
|
11729 |
|
11730 | var Map = getNative(root, 'Map'),
|
11731 | nativeCreate = getNative(Object, 'create');
|
11732 |
|
11733 |
|
11734 | var symbolProto = Symbol ? Symbol.prototype : undefined,
|
11735 | symbolToString = symbolProto ? symbolProto.toString : undefined;
|
11736 |
|
11737 |
|
11738 |
|
11739 |
|
11740 |
|
11741 |
|
11742 |
|
11743 |
|
11744 | function 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 |
|
11757 |
|
11758 |
|
11759 |
|
11760 |
|
11761 |
|
11762 | function hashClear() {
|
11763 | this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
11764 | }
|
11765 |
|
11766 |
|
11767 |
|
11768 |
|
11769 |
|
11770 |
|
11771 |
|
11772 |
|
11773 |
|
11774 |
|
11775 |
|
11776 | function hashDelete(key) {
|
11777 | return this.has(key) && delete this.__data__[key];
|
11778 | }
|
11779 |
|
11780 |
|
11781 |
|
11782 |
|
11783 |
|
11784 |
|
11785 |
|
11786 |
|
11787 |
|
11788 |
|
11789 | function 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 |
|
11800 |
|
11801 |
|
11802 |
|
11803 |
|
11804 |
|
11805 |
|
11806 |
|
11807 | function hashHas(key) {
|
11808 | var data = this.__data__;
|
11809 | return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
11810 | }
|
11811 |
|
11812 |
|
11813 |
|
11814 |
|
11815 |
|
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 |
|
11821 |
|
11822 | function hashSet(key, value) {
|
11823 | var data = this.__data__;
|
11824 | data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
11825 | return this;
|
11826 | }
|
11827 |
|
11828 |
|
11829 | Hash.prototype.clear = hashClear;
|
11830 | Hash.prototype['delete'] = hashDelete;
|
11831 | Hash.prototype.get = hashGet;
|
11832 | Hash.prototype.has = hashHas;
|
11833 | Hash.prototype.set = hashSet;
|
11834 |
|
11835 |
|
11836 |
|
11837 |
|
11838 |
|
11839 |
|
11840 |
|
11841 |
|
11842 | function 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 |
|
11855 |
|
11856 |
|
11857 |
|
11858 |
|
11859 |
|
11860 | function listCacheClear() {
|
11861 | this.__data__ = [];
|
11862 | }
|
11863 |
|
11864 |
|
11865 |
|
11866 |
|
11867 |
|
11868 |
|
11869 |
|
11870 |
|
11871 |
|
11872 |
|
11873 | function 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 |
|
11891 |
|
11892 |
|
11893 |
|
11894 |
|
11895 |
|
11896 |
|
11897 |
|
11898 | function 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 |
|
11907 |
|
11908 |
|
11909 |
|
11910 |
|
11911 |
|
11912 |
|
11913 |
|
11914 | function listCacheHas(key) {
|
11915 | return assocIndexOf(this.__data__, key) > -1;
|
11916 | }
|
11917 |
|
11918 |
|
11919 |
|
11920 |
|
11921 |
|
11922 |
|
11923 |
|
11924 |
|
11925 |
|
11926 |
|
11927 |
|
11928 | function 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 |
|
11941 | ListCache.prototype.clear = listCacheClear;
|
11942 | ListCache.prototype['delete'] = listCacheDelete;
|
11943 | ListCache.prototype.get = listCacheGet;
|
11944 | ListCache.prototype.has = listCacheHas;
|
11945 | ListCache.prototype.set = listCacheSet;
|
11946 |
|
11947 |
|
11948 |
|
11949 |
|
11950 |
|
11951 |
|
11952 |
|
11953 |
|
11954 | function 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 |
|
11967 |
|
11968 |
|
11969 |
|
11970 |
|
11971 |
|
11972 | function mapCacheClear() {
|
11973 | this.__data__ = {
|
11974 | 'hash': new Hash,
|
11975 | 'map': new (Map || ListCache),
|
11976 | 'string': new Hash
|
11977 | };
|
11978 | }
|
11979 |
|
11980 |
|
11981 |
|
11982 |
|
11983 |
|
11984 |
|
11985 |
|
11986 |
|
11987 |
|
11988 |
|
11989 | function mapCacheDelete(key) {
|
11990 | return getMapData(this, key)['delete'](key);
|
11991 | }
|
11992 |
|
11993 |
|
11994 |
|
11995 |
|
11996 |
|
11997 |
|
11998 |
|
11999 |
|
12000 |
|
12001 |
|
12002 | function mapCacheGet(key) {
|
12003 | return getMapData(this, key).get(key);
|
12004 | }
|
12005 |
|
12006 |
|
12007 |
|
12008 |
|
12009 |
|
12010 |
|
12011 |
|
12012 |
|
12013 |
|
12014 |
|
12015 | function mapCacheHas(key) {
|
12016 | return getMapData(this, key).has(key);
|
12017 | }
|
12018 |
|
12019 |
|
12020 |
|
12021 |
|
12022 |
|
12023 |
|
12024 |
|
12025 |
|
12026 |
|
12027 |
|
12028 |
|
12029 | function mapCacheSet(key, value) {
|
12030 | getMapData(this, key).set(key, value);
|
12031 | return this;
|
12032 | }
|
12033 |
|
12034 |
|
12035 | MapCache.prototype.clear = mapCacheClear;
|
12036 | MapCache.prototype['delete'] = mapCacheDelete;
|
12037 | MapCache.prototype.get = mapCacheGet;
|
12038 | MapCache.prototype.has = mapCacheHas;
|
12039 | MapCache.prototype.set = mapCacheSet;
|
12040 |
|
12041 |
|
12042 |
|
12043 |
|
12044 |
|
12045 |
|
12046 |
|
12047 |
|
12048 |
|
12049 | function 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 |
|
12061 |
|
12062 |
|
12063 |
|
12064 |
|
12065 |
|
12066 |
|
12067 | function 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 |
|
12081 |
|
12082 |
|
12083 |
|
12084 |
|
12085 |
|
12086 |
|
12087 | function 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 |
|
12097 |
|
12098 |
|
12099 |
|
12100 |
|
12101 |
|
12102 |
|
12103 | function baseToString(value) {
|
12104 |
|
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 |
|
12117 |
|
12118 |
|
12119 |
|
12120 |
|
12121 |
|
12122 | function castPath(value) {
|
12123 | return isArray(value) ? value : stringToPath(value);
|
12124 | }
|
12125 |
|
12126 |
|
12127 |
|
12128 |
|
12129 |
|
12130 |
|
12131 |
|
12132 |
|
12133 |
|
12134 | function 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 |
|
12143 |
|
12144 |
|
12145 |
|
12146 |
|
12147 |
|
12148 |
|
12149 | function getNative(object, key) {
|
12150 | var value = getValue(object, key);
|
12151 | return baseIsNative(value) ? value : undefined;
|
12152 | }
|
12153 |
|
12154 |
|
12155 |
|
12156 |
|
12157 |
|
12158 |
|
12159 |
|
12160 |
|
12161 |
|
12162 | function 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 |
|
12177 |
|
12178 |
|
12179 |
|
12180 |
|
12181 |
|
12182 | function 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 |
|
12191 |
|
12192 |
|
12193 |
|
12194 |
|
12195 |
|
12196 | function isMasked(func) {
|
12197 | return !!maskSrcKey && (maskSrcKey in func);
|
12198 | }
|
12199 |
|
12200 |
|
12201 |
|
12202 |
|
12203 |
|
12204 |
|
12205 |
|
12206 |
|
12207 | var 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 |
|
12222 |
|
12223 |
|
12224 |
|
12225 |
|
12226 |
|
12227 | function 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 |
|
12237 |
|
12238 |
|
12239 |
|
12240 |
|
12241 |
|
12242 | function 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 |
|
12256 |
|
12257 |
|
12258 |
|
12259 |
|
12260 |
|
12261 |
|
12262 |
|
12263 |
|
12264 |
|
12265 |
|
12266 |
|
12267 |
|
12268 |
|
12269 |
|
12270 |
|
12271 |
|
12272 |
|
12273 |
|
12274 |
|
12275 |
|
12276 |
|
12277 |
|
12278 |
|
12279 |
|
12280 |
|
12281 |
|
12282 |
|
12283 |
|
12284 |
|
12285 |
|
12286 |
|
12287 |
|
12288 |
|
12289 |
|
12290 |
|
12291 |
|
12292 |
|
12293 |
|
12294 |
|
12295 |
|
12296 |
|
12297 |
|
12298 | function 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 |
|
12319 | memoize.Cache = MapCache;
|
12320 |
|
12321 |
|
12322 |
|
12323 |
|
12324 |
|
12325 |
|
12326 |
|
12327 |
|
12328 |
|
12329 |
|
12330 |
|
12331 |
|
12332 |
|
12333 |
|
12334 |
|
12335 |
|
12336 |
|
12337 |
|
12338 |
|
12339 |
|
12340 |
|
12341 |
|
12342 |
|
12343 |
|
12344 |
|
12345 |
|
12346 |
|
12347 |
|
12348 |
|
12349 |
|
12350 |
|
12351 |
|
12352 |
|
12353 | function eq(value, other) {
|
12354 | return value === other || (value !== value && other !== other);
|
12355 | }
|
12356 |
|
12357 |
|
12358 |
|
12359 |
|
12360 |
|
12361 |
|
12362 |
|
12363 |
|
12364 |
|
12365 |
|
12366 |
|
12367 |
|
12368 |
|
12369 |
|
12370 |
|
12371 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 |
|
12378 |
|
12379 |
|
12380 | var isArray = Array.isArray;
|
12381 |
|
12382 |
|
12383 |
|
12384 |
|
12385 |
|
12386 |
|
12387 |
|
12388 |
|
12389 |
|
12390 |
|
12391 |
|
12392 |
|
12393 |
|
12394 |
|
12395 |
|
12396 |
|
12397 |
|
12398 |
|
12399 | function isFunction(value) {
|
12400 |
|
12401 |
|
12402 | var tag = isObject(value) ? objectToString.call(value) : '';
|
12403 | return tag == funcTag || tag == genTag;
|
12404 | }
|
12405 |
|
12406 |
|
12407 |
|
12408 |
|
12409 |
|
12410 |
|
12411 |
|
12412 |
|
12413 |
|
12414 |
|
12415 |
|
12416 |
|
12417 |
|
12418 |
|
12419 |
|
12420 |
|
12421 |
|
12422 |
|
12423 |
|
12424 |
|
12425 |
|
12426 |
|
12427 |
|
12428 |
|
12429 |
|
12430 |
|
12431 | function isObject(value) {
|
12432 | var type = typeof value;
|
12433 | return !!value && (type == 'object' || type == 'function');
|
12434 | }
|
12435 |
|
12436 |
|
12437 |
|
12438 |
|
12439 |
|
12440 |
|
12441 |
|
12442 |
|
12443 |
|
12444 |
|
12445 |
|
12446 |
|
12447 |
|
12448 |
|
12449 |
|
12450 |
|
12451 |
|
12452 |
|
12453 |
|
12454 |
|
12455 |
|
12456 |
|
12457 |
|
12458 |
|
12459 |
|
12460 | function isObjectLike(value) {
|
12461 | return !!value && typeof value == 'object';
|
12462 | }
|
12463 |
|
12464 |
|
12465 |
|
12466 |
|
12467 |
|
12468 |
|
12469 |
|
12470 |
|
12471 |
|
12472 |
|
12473 |
|
12474 |
|
12475 |
|
12476 |
|
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 | function isSymbol(value) {
|
12482 | return typeof value == 'symbol' ||
|
12483 | (isObjectLike(value) && objectToString.call(value) == symbolTag);
|
12484 | }
|
12485 |
|
12486 |
|
12487 |
|
12488 |
|
12489 |
|
12490 |
|
12491 |
|
12492 |
|
12493 |
|
12494 |
|
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 |
|
12504 |
|
12505 |
|
12506 |
|
12507 | function toString(value) {
|
12508 | return value == null ? '' : baseToString(value);
|
12509 | }
|
12510 |
|
12511 |
|
12512 |
|
12513 |
|
12514 |
|
12515 |
|
12516 |
|
12517 |
|
12518 |
|
12519 |
|
12520 |
|
12521 |
|
12522 |
|
12523 |
|
12524 |
|
12525 |
|
12526 |
|
12527 |
|
12528 |
|
12529 |
|
12530 |
|
12531 |
|
12532 |
|
12533 |
|
12534 |
|
12535 |
|
12536 | function get(object, path, defaultValue) {
|
12537 | var result = object == null ? undefined : baseGet(object, path);
|
12538 | return result === undefined ? defaultValue : result;
|
12539 | }
|
12540 |
|
12541 | module.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 |
|
12549 |
|
12550 |
|
12551 |
|
12552 |
|
12553 |
|
12554 |
|
12555 |
|
12556 |
|
12557 | var LARGE_ARRAY_SIZE = 200;
|
12558 |
|
12559 |
|
12560 | var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
12561 |
|
12562 |
|
12563 | var COMPARE_PARTIAL_FLAG = 1,
|
12564 | COMPARE_UNORDERED_FLAG = 2;
|
12565 |
|
12566 |
|
12567 | var MAX_SAFE_INTEGER = 9007199254740991;
|
12568 |
|
12569 |
|
12570 | var 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 |
|
12591 | var 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 |
|
12605 |
|
12606 |
|
12607 | var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
12608 |
|
12609 |
|
12610 | var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
12611 |
|
12612 |
|
12613 | var reIsUint = /^(?:0|[1-9]\d*)$/;
|
12614 |
|
12615 |
|
12616 | var typedArrayTags = {};
|
12617 | typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
12618 | typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
12619 | typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
12620 | typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
12621 | typedArrayTags[uint32Tag] = true;
|
12622 | typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
12623 | typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
12624 | typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
12625 | typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
12626 | typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
12627 | typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
12628 | typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
12629 | typedArrayTags[weakMapTag] = false;
|
12630 |
|
12631 |
|
12632 | var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
12633 |
|
12634 |
|
12635 | var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
12636 |
|
12637 |
|
12638 | var root = freeGlobal || freeSelf || Function('return this')();
|
12639 |
|
12640 |
|
12641 | var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
12642 |
|
12643 |
|
12644 | var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
12645 |
|
12646 |
|
12647 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
12648 |
|
12649 |
|
12650 | var freeProcess = moduleExports && freeGlobal.process;
|
12651 |
|
12652 |
|
12653 | var nodeUtil = (function() {
|
12654 | try {
|
12655 | return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
12656 | } catch (e) {}
|
12657 | }());
|
12658 |
|
12659 |
|
12660 | var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
12661 |
|
12662 |
|
12663 |
|
12664 |
|
12665 |
|
12666 |
|
12667 |
|
12668 |
|
12669 |
|
12670 |
|
12671 | function 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 |
|
12688 |
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 |
|
12694 | function 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 |
|
12707 |
|
12708 |
|
12709 |
|
12710 |
|
12711 |
|
12712 |
|
12713 |
|
12714 |
|
12715 | function 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 |
|
12729 |
|
12730 |
|
12731 |
|
12732 |
|
12733 |
|
12734 |
|
12735 |
|
12736 | function 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 |
|
12748 |
|
12749 |
|
12750 |
|
12751 |
|
12752 |
|
12753 | function baseUnary(func) {
|
12754 | return function(value) {
|
12755 | return func(value);
|
12756 | };
|
12757 | }
|
12758 |
|
12759 |
|
12760 |
|
12761 |
|
12762 |
|
12763 |
|
12764 |
|
12765 |
|
12766 |
|
12767 | function cacheHas(cache, key) {
|
12768 | return cache.has(key);
|
12769 | }
|
12770 |
|
12771 |
|
12772 |
|
12773 |
|
12774 |
|
12775 |
|
12776 |
|
12777 |
|
12778 |
|
12779 | function getValue(object, key) {
|
12780 | return object == null ? undefined : object[key];
|
12781 | }
|
12782 |
|
12783 |
|
12784 |
|
12785 |
|
12786 |
|
12787 |
|
12788 |
|
12789 |
|
12790 | function 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 |
|
12802 |
|
12803 |
|
12804 |
|
12805 |
|
12806 |
|
12807 |
|
12808 | function overArg(func, transform) {
|
12809 | return function(arg) {
|
12810 | return func(transform(arg));
|
12811 | };
|
12812 | }
|
12813 |
|
12814 |
|
12815 |
|
12816 |
|
12817 |
|
12818 |
|
12819 |
|
12820 |
|
12821 | function 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 |
|
12832 | var arrayProto = Array.prototype,
|
12833 | funcProto = Function.prototype,
|
12834 | objectProto = Object.prototype;
|
12835 |
|
12836 |
|
12837 | var coreJsData = root['__core-js_shared__'];
|
12838 |
|
12839 |
|
12840 | var funcToString = funcProto.toString;
|
12841 |
|
12842 |
|
12843 | var hasOwnProperty = objectProto.hasOwnProperty;
|
12844 |
|
12845 |
|
12846 | var maskSrcKey = (function() {
|
12847 | var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
12848 | return uid ? ('Symbol(src)_1.' + uid) : '';
|
12849 | }());
|
12850 |
|
12851 |
|
12852 |
|
12853 |
|
12854 |
|
12855 |
|
12856 | var nativeObjectToString = objectProto.toString;
|
12857 |
|
12858 |
|
12859 | var reIsNative = RegExp('^' +
|
12860 | funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
12861 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
12862 | );
|
12863 |
|
12864 |
|
12865 | var 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 |
|
12873 | var nativeGetSymbols = Object.getOwnPropertySymbols,
|
12874 | nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
12875 | nativeKeys = overArg(Object.keys, Object);
|
12876 |
|
12877 |
|
12878 | var 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 |
|
12886 | var dataViewCtorString = toSource(DataView),
|
12887 | mapCtorString = toSource(Map),
|
12888 | promiseCtorString = toSource(Promise),
|
12889 | setCtorString = toSource(Set),
|
12890 | weakMapCtorString = toSource(WeakMap);
|
12891 |
|
12892 |
|
12893 | var symbolProto = Symbol ? Symbol.prototype : undefined,
|
12894 | symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
12895 |
|
12896 |
|
12897 |
|
12898 |
|
12899 |
|
12900 |
|
12901 |
|
12902 |
|
12903 | function 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 |
|
12916 |
|
12917 |
|
12918 |
|
12919 |
|
12920 |
|
12921 | function hashClear() {
|
12922 | this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
12923 | this.size = 0;
|
12924 | }
|
12925 |
|
12926 |
|
12927 |
|
12928 |
|
12929 |
|
12930 |
|
12931 |
|
12932 |
|
12933 |
|
12934 |
|
12935 |
|
12936 | function 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 |
|
12944 |
|
12945 |
|
12946 |
|
12947 |
|
12948 |
|
12949 |
|
12950 |
|
12951 | function 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 |
|
12962 |
|
12963 |
|
12964 |
|
12965 |
|
12966 |
|
12967 |
|
12968 |
|
12969 | function hashHas(key) {
|
12970 | var data = this.__data__;
|
12971 | return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
12972 | }
|
12973 |
|
12974 |
|
12975 |
|
12976 |
|
12977 |
|
12978 |
|
12979 |
|
12980 |
|
12981 |
|
12982 |
|
12983 |
|
12984 | function 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 |
|
12992 | Hash.prototype.clear = hashClear;
|
12993 | Hash.prototype['delete'] = hashDelete;
|
12994 | Hash.prototype.get = hashGet;
|
12995 | Hash.prototype.has = hashHas;
|
12996 | Hash.prototype.set = hashSet;
|
12997 |
|
12998 |
|
12999 |
|
13000 |
|
13001 |
|
13002 |
|
13003 |
|
13004 |
|
13005 | function 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 |
|
13018 |
|
13019 |
|
13020 |
|
13021 |
|
13022 |
|
13023 | function listCacheClear() {
|
13024 | this.__data__ = [];
|
13025 | this.size = 0;
|
13026 | }
|
13027 |
|
13028 |
|
13029 |
|
13030 |
|
13031 |
|
13032 |
|
13033 |
|
13034 |
|
13035 |
|
13036 |
|
13037 | function 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 |
|
13056 |
|
13057 |
|
13058 |
|
13059 |
|
13060 |
|
13061 |
|
13062 |
|
13063 | function 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 |
|
13072 |
|
13073 |
|
13074 |
|
13075 |
|
13076 |
|
13077 |
|
13078 |
|
13079 | function listCacheHas(key) {
|
13080 | return assocIndexOf(this.__data__, key) > -1;
|
13081 | }
|
13082 |
|
13083 |
|
13084 |
|
13085 |
|
13086 |
|
13087 |
|
13088 |
|
13089 |
|
13090 |
|
13091 |
|
13092 |
|
13093 | function 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 |
|
13107 | ListCache.prototype.clear = listCacheClear;
|
13108 | ListCache.prototype['delete'] = listCacheDelete;
|
13109 | ListCache.prototype.get = listCacheGet;
|
13110 | ListCache.prototype.has = listCacheHas;
|
13111 | ListCache.prototype.set = listCacheSet;
|
13112 |
|
13113 |
|
13114 |
|
13115 |
|
13116 |
|
13117 |
|
13118 |
|
13119 |
|
13120 | function 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 |
|
13133 |
|
13134 |
|
13135 |
|
13136 |
|
13137 |
|
13138 | function 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 |
|
13149 |
|
13150 |
|
13151 |
|
13152 |
|
13153 |
|
13154 |
|
13155 |
|
13156 | function mapCacheDelete(key) {
|
13157 | var result = getMapData(this, key)['delete'](key);
|
13158 | this.size -= result ? 1 : 0;
|
13159 | return result;
|
13160 | }
|
13161 |
|
13162 |
|
13163 |
|
13164 |
|
13165 |
|
13166 |
|
13167 |
|
13168 |
|
13169 |
|
13170 |
|
13171 | function mapCacheGet(key) {
|
13172 | return getMapData(this, key).get(key);
|
13173 | }
|
13174 |
|
13175 |
|
13176 |
|
13177 |
|
13178 |
|
13179 |
|
13180 |
|
13181 |
|
13182 |
|
13183 |
|
13184 | function mapCacheHas(key) {
|
13185 | return getMapData(this, key).has(key);
|
13186 | }
|
13187 |
|
13188 |
|
13189 |
|
13190 |
|
13191 |
|
13192 |
|
13193 |
|
13194 |
|
13195 |
|
13196 |
|
13197 |
|
13198 | function 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 |
|
13208 | MapCache.prototype.clear = mapCacheClear;
|
13209 | MapCache.prototype['delete'] = mapCacheDelete;
|
13210 | MapCache.prototype.get = mapCacheGet;
|
13211 | MapCache.prototype.has = mapCacheHas;
|
13212 | MapCache.prototype.set = mapCacheSet;
|
13213 |
|
13214 |
|
13215 |
|
13216 |
|
13217 |
|
13218 |
|
13219 |
|
13220 |
|
13221 |
|
13222 | function 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 |
|
13234 |
|
13235 |
|
13236 |
|
13237 |
|
13238 |
|
13239 |
|
13240 |
|
13241 |
|
13242 | function setCacheAdd(value) {
|
13243 | this.__data__.set(value, HASH_UNDEFINED);
|
13244 | return this;
|
13245 | }
|
13246 |
|
13247 |
|
13248 |
|
13249 |
|
13250 |
|
13251 |
|
13252 |
|
13253 |
|
13254 |
|
13255 |
|
13256 | function setCacheHas(value) {
|
13257 | return this.__data__.has(value);
|
13258 | }
|
13259 |
|
13260 |
|
13261 | SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
13262 | SetCache.prototype.has = setCacheHas;
|
13263 |
|
13264 |
|
13265 |
|
13266 |
|
13267 |
|
13268 |
|
13269 |
|
13270 |
|
13271 | function Stack(entries) {
|
13272 | var data = this.__data__ = new ListCache(entries);
|
13273 | this.size = data.size;
|
13274 | }
|
13275 |
|
13276 |
|
13277 |
|
13278 |
|
13279 |
|
13280 |
|
13281 |
|
13282 |
|
13283 | function stackClear() {
|
13284 | this.__data__ = new ListCache;
|
13285 | this.size = 0;
|
13286 | }
|
13287 |
|
13288 |
|
13289 |
|
13290 |
|
13291 |
|
13292 |
|
13293 |
|
13294 |
|
13295 |
|
13296 |
|
13297 | function 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 |
|
13307 |
|
13308 |
|
13309 |
|
13310 |
|
13311 |
|
13312 |
|
13313 |
|
13314 | function stackGet(key) {
|
13315 | return this.__data__.get(key);
|
13316 | }
|
13317 |
|
13318 |
|
13319 |
|
13320 |
|
13321 |
|
13322 |
|
13323 |
|
13324 |
|
13325 |
|
13326 |
|
13327 | function stackHas(key) {
|
13328 | return this.__data__.has(key);
|
13329 | }
|
13330 |
|
13331 |
|
13332 |
|
13333 |
|
13334 |
|
13335 |
|
13336 |
|
13337 |
|
13338 |
|
13339 |
|
13340 |
|
13341 | function 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 |
|
13358 | Stack.prototype.clear = stackClear;
|
13359 | Stack.prototype['delete'] = stackDelete;
|
13360 | Stack.prototype.get = stackGet;
|
13361 | Stack.prototype.has = stackHas;
|
13362 | Stack.prototype.set = stackSet;
|
13363 |
|
13364 |
|
13365 |
|
13366 |
|
13367 |
|
13368 |
|
13369 |
|
13370 |
|
13371 |
|
13372 | function 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 |
|
13385 | key == 'length' ||
|
13386 |
|
13387 | (isBuff && (key == 'offset' || key == 'parent')) ||
|
13388 |
|
13389 | (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
13390 |
|
13391 | isIndex(key, length)
|
13392 | ))) {
|
13393 | result.push(key);
|
13394 | }
|
13395 | }
|
13396 | return result;
|
13397 | }
|
13398 |
|
13399 |
|
13400 |
|
13401 |
|
13402 |
|
13403 |
|
13404 |
|
13405 |
|
13406 |
|
13407 | function 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 |
|
13419 |
|
13420 |
|
13421 |
|
13422 |
|
13423 |
|
13424 |
|
13425 |
|
13426 |
|
13427 |
|
13428 | function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
13429 | var result = keysFunc(object);
|
13430 | return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
13431 | }
|
13432 |
|
13433 |
|
13434 |
|
13435 |
|
13436 |
|
13437 |
|
13438 |
|
13439 |
|
13440 | function 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 |
|
13451 |
|
13452 |
|
13453 |
|
13454 |
|
13455 |
|
13456 | function baseIsArguments(value) {
|
13457 | return isObjectLike(value) && baseGetTag(value) == argsTag;
|
13458 | }
|
13459 |
|
13460 |
|
13461 |
|
13462 |
|
13463 |
|
13464 |
|
13465 |
|
13466 |
|
13467 |
|
13468 |
|
13469 |
|
13470 |
|
13471 |
|
13472 |
|
13473 |
|
13474 | function 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 |
|
13486 |
|
13487 |
|
13488 |
|
13489 |
|
13490 |
|
13491 |
|
13492 |
|
13493 |
|
13494 |
|
13495 |
|
13496 |
|
13497 |
|
13498 | function 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 |
|
13545 |
|
13546 |
|
13547 |
|
13548 |
|
13549 |
|
13550 |
|
13551 | function 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 |
|
13561 |
|
13562 |
|
13563 |
|
13564 |
|
13565 |
|
13566 | function baseIsTypedArray(value) {
|
13567 | return isObjectLike(value) &&
|
13568 | isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
13569 | }
|
13570 |
|
13571 |
|
13572 |
|
13573 |
|
13574 |
|
13575 |
|
13576 |
|
13577 |
|
13578 | function 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 |
|
13593 |
|
13594 |
|
13595 |
|
13596 |
|
13597 |
|
13598 |
|
13599 |
|
13600 |
|
13601 |
|
13602 |
|
13603 |
|
13604 | function 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 |
|
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 |
|
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 |
|
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 |
|
13667 |
|
13668 |
|
13669 |
|
13670 |
|
13671 |
|
13672 |
|
13673 |
|
13674 |
|
13675 |
|
13676 |
|
13677 |
|
13678 |
|
13679 |
|
13680 |
|
13681 |
|
13682 | function 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 |
|
13703 |
|
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 |
|
13712 |
|
13713 |
|
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 |
|
13727 | var stacked = stack.get(object);
|
13728 | if (stacked) {
|
13729 | return stacked == other;
|
13730 | }
|
13731 | bitmask |= COMPARE_UNORDERED_FLAG;
|
13732 |
|
13733 |
|
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 |
|
13749 |
|
13750 |
|
13751 |
|
13752 |
|
13753 |
|
13754 |
|
13755 |
|
13756 |
|
13757 |
|
13758 |
|
13759 |
|
13760 | function 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 |
|
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 |
|
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 |
|
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 |
|
13826 |
|
13827 |
|
13828 |
|
13829 |
|
13830 |
|
13831 | function getAllKeys(object) {
|
13832 | return baseGetAllKeys(object, keys, getSymbols);
|
13833 | }
|
13834 |
|
13835 |
|
13836 |
|
13837 |
|
13838 |
|
13839 |
|
13840 |
|
13841 |
|
13842 |
|
13843 | function 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 |
|
13852 |
|
13853 |
|
13854 |
|
13855 |
|
13856 |
|
13857 |
|
13858 | function getNative(object, key) {
|
13859 | var value = getValue(object, key);
|
13860 | return baseIsNative(value) ? value : undefined;
|
13861 | }
|
13862 |
|
13863 |
|
13864 |
|
13865 |
|
13866 |
|
13867 |
|
13868 |
|
13869 |
|
13870 | function 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 |
|
13892 |
|
13893 |
|
13894 |
|
13895 |
|
13896 |
|
13897 | var 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 |
|
13909 |
|
13910 |
|
13911 |
|
13912 |
|
13913 |
|
13914 | var getTag = baseGetTag;
|
13915 |
|
13916 |
|
13917 | if ((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 |
|
13942 |
|
13943 |
|
13944 |
|
13945 |
|
13946 |
|
13947 |
|
13948 | function 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 |
|
13957 |
|
13958 |
|
13959 |
|
13960 |
|
13961 |
|
13962 | function 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 |
|
13971 |
|
13972 |
|
13973 |
|
13974 |
|
13975 |
|
13976 | function isMasked(func) {
|
13977 | return !!maskSrcKey && (maskSrcKey in func);
|
13978 | }
|
13979 |
|
13980 |
|
13981 |
|
13982 |
|
13983 |
|
13984 |
|
13985 |
|
13986 |
|
13987 | function 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 |
|
13996 |
|
13997 |
|
13998 |
|
13999 |
|
14000 |
|
14001 | function objectToString(value) {
|
14002 | return nativeObjectToString.call(value);
|
14003 | }
|
14004 |
|
14005 |
|
14006 |
|
14007 |
|
14008 |
|
14009 |
|
14010 |
|
14011 |
|
14012 | function 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 |
|
14026 |
|
14027 |
|
14028 |
|
14029 |
|
14030 |
|
14031 |
|
14032 |
|
14033 |
|
14034 |
|
14035 |
|
14036 |
|
14037 |
|
14038 |
|
14039 |
|
14040 |
|
14041 |
|
14042 |
|
14043 |
|
14044 |
|
14045 |
|
14046 |
|
14047 |
|
14048 |
|
14049 |
|
14050 |
|
14051 |
|
14052 |
|
14053 |
|
14054 |
|
14055 |
|
14056 | function eq(value, other) {
|
14057 | return value === other || (value !== value && other !== other);
|
14058 | }
|
14059 |
|
14060 |
|
14061 |
|
14062 |
|
14063 |
|
14064 |
|
14065 |
|
14066 |
|
14067 |
|
14068 |
|
14069 |
|
14070 |
|
14071 |
|
14072 |
|
14073 |
|
14074 |
|
14075 |
|
14076 |
|
14077 |
|
14078 | var 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 |
|
14085 |
|
14086 |
|
14087 |
|
14088 |
|
14089 |
|
14090 |
|
14091 |
|
14092 |
|
14093 |
|
14094 |
|
14095 |
|
14096 |
|
14097 |
|
14098 |
|
14099 |
|
14100 |
|
14101 |
|
14102 |
|
14103 |
|
14104 |
|
14105 |
|
14106 | var isArray = Array.isArray;
|
14107 |
|
14108 |
|
14109 |
|
14110 |
|
14111 |
|
14112 |
|
14113 |
|
14114 |
|
14115 |
|
14116 |
|
14117 |
|
14118 |
|
14119 |
|
14120 |
|
14121 |
|
14122 |
|
14123 |
|
14124 |
|
14125 |
|
14126 |
|
14127 |
|
14128 |
|
14129 |
|
14130 |
|
14131 |
|
14132 |
|
14133 | function isArrayLike(value) {
|
14134 | return value != null && isLength(value.length) && !isFunction(value);
|
14135 | }
|
14136 |
|
14137 |
|
14138 |
|
14139 |
|
14140 |
|
14141 |
|
14142 |
|
14143 |
|
14144 |
|
14145 |
|
14146 |
|
14147 |
|
14148 |
|
14149 |
|
14150 |
|
14151 |
|
14152 |
|
14153 |
|
14154 | var isBuffer = nativeIsBuffer || stubFalse;
|
14155 |
|
14156 |
|
14157 |
|
14158 |
|
14159 |
|
14160 |
|
14161 |
|
14162 |
|
14163 |
|
14164 |
|
14165 |
|
14166 |
|
14167 |
|
14168 |
|
14169 |
|
14170 |
|
14171 |
|
14172 |
|
14173 |
|
14174 |
|
14175 |
|
14176 |
|
14177 |
|
14178 |
|
14179 |
|
14180 |
|
14181 |
|
14182 |
|
14183 |
|
14184 | function isEqual(value, other) {
|
14185 | return baseIsEqual(value, other);
|
14186 | }
|
14187 |
|
14188 |
|
14189 |
|
14190 |
|
14191 |
|
14192 |
|
14193 |
|
14194 |
|
14195 |
|
14196 |
|
14197 |
|
14198 |
|
14199 |
|
14200 |
|
14201 |
|
14202 |
|
14203 |
|
14204 |
|
14205 | function isFunction(value) {
|
14206 | if (!isObject(value)) {
|
14207 | return false;
|
14208 | }
|
14209 |
|
14210 |
|
14211 | var tag = baseGetTag(value);
|
14212 | return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
14213 | }
|
14214 |
|
14215 |
|
14216 |
|
14217 |
|
14218 |
|
14219 |
|
14220 |
|
14221 |
|
14222 |
|
14223 |
|
14224 |
|
14225 |
|
14226 |
|
14227 |
|
14228 |
|
14229 |
|
14230 |
|
14231 |
|
14232 |
|
14233 |
|
14234 |
|
14235 |
|
14236 |
|
14237 |
|
14238 |
|
14239 |
|
14240 |
|
14241 | function isLength(value) {
|
14242 | return typeof value == 'number' &&
|
14243 | value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
14244 | }
|
14245 |
|
14246 |
|
14247 |
|
14248 |
|
14249 |
|
14250 |
|
14251 |
|
14252 |
|
14253 |
|
14254 |
|
14255 |
|
14256 |
|
14257 |
|
14258 |
|
14259 |
|
14260 |
|
14261 |
|
14262 |
|
14263 |
|
14264 |
|
14265 |
|
14266 |
|
14267 |
|
14268 |
|
14269 |
|
14270 |
|
14271 | function isObject(value) {
|
14272 | var type = typeof value;
|
14273 | return value != null && (type == 'object' || type == 'function');
|
14274 | }
|
14275 |
|
14276 |
|
14277 |
|
14278 |
|
14279 |
|
14280 |
|
14281 |
|
14282 |
|
14283 |
|
14284 |
|
14285 |
|
14286 |
|
14287 |
|
14288 |
|
14289 |
|
14290 |
|
14291 |
|
14292 |
|
14293 |
|
14294 |
|
14295 |
|
14296 |
|
14297 |
|
14298 |
|
14299 |
|
14300 | function isObjectLike(value) {
|
14301 | return value != null && typeof value == 'object';
|
14302 | }
|
14303 |
|
14304 |
|
14305 |
|
14306 |
|
14307 |
|
14308 |
|
14309 |
|
14310 |
|
14311 |
|
14312 |
|
14313 |
|
14314 |
|
14315 |
|
14316 |
|
14317 |
|
14318 |
|
14319 |
|
14320 |
|
14321 | var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
14322 |
|
14323 |
|
14324 |
|
14325 |
|
14326 |
|
14327 |
|
14328 |
|
14329 |
|
14330 |
|
14331 |
|
14332 |
|
14333 |
|
14334 |
|
14335 |
|
14336 |
|
14337 |
|
14338 |
|
14339 |
|
14340 |
|
14341 |
|
14342 |
|
14343 |
|
14344 |
|
14345 |
|
14346 |
|
14347 |
|
14348 |
|
14349 |
|
14350 |
|
14351 | function keys(object) {
|
14352 | return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
14353 | }
|
14354 |
|
14355 |
|
14356 |
|
14357 |
|
14358 |
|
14359 |
|
14360 |
|
14361 |
|
14362 |
|
14363 |
|
14364 |
|
14365 |
|
14366 |
|
14367 |
|
14368 |
|
14369 |
|
14370 |
|
14371 |
|
14372 |
|
14373 | function stubArray() {
|
14374 | return [];
|
14375 | }
|
14376 |
|
14377 |
|
14378 |
|
14379 |
|
14380 |
|
14381 |
|
14382 |
|
14383 |
|
14384 |
|
14385 |
|
14386 |
|
14387 |
|
14388 |
|
14389 |
|
14390 | function stubFalse() {
|
14391 | return false;
|
14392 | }
|
14393 |
|
14394 | module.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 |
|
14401 | var format = require("format-util");
|
14402 | var slice = Array.prototype.slice;
|
14403 | var protectedProperties = ["name", "message", "stack"];
|
14404 | var errorPrototypeProperties = [
|
14405 | "name", "message", "description", "number", "code", "fileName", "lineNumber", "columnNumber",
|
14406 | "sourceURL", "line", "column", "stack"
|
14407 | ];
|
14408 |
|
14409 | module.exports = create(Error);
|
14410 | module.exports.error = create(Error);
|
14411 | module.exports.eval = create(EvalError);
|
14412 | module.exports.range = create(RangeError);
|
14413 | module.exports.reference = create(ReferenceError);
|
14414 | module.exports.syntax = create(SyntaxError);
|
14415 | module.exports.type = create(TypeError);
|
14416 | module.exports.uri = create(URIError);
|
14417 | module.exports.formatter = format;
|
14418 |
|
14419 |
|
14420 |
|
14421 |
|
14422 |
|
14423 |
|
14424 |
|
14425 | function create (Klass) {
|
14426 | |
14427 |
|
14428 |
|
14429 |
|
14430 |
|
14431 |
|
14432 |
|
14433 | return function onoFactory (err, props, message, params) {
|
14434 | var formatArgs = [];
|
14435 | var formattedMessage = "";
|
14436 |
|
14437 |
|
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 |
|
14451 | if (formatArgs.length > 0) {
|
14452 | formattedMessage = module.exports.formatter.apply(null, formatArgs);
|
14453 | }
|
14454 |
|
14455 | if (err && err.message) {
|
14456 |
|
14457 | formattedMessage += (formattedMessage ? " \n" : "") + err.message;
|
14458 | }
|
14459 |
|
14460 |
|
14461 |
|
14462 | var newError = new Klass(formattedMessage);
|
14463 |
|
14464 |
|
14465 | extendError(newError, err);
|
14466 | extendToJSON(newError);
|
14467 | extend(newError, props);
|
14468 |
|
14469 | return newError;
|
14470 | };
|
14471 | }
|
14472 |
|
14473 |
|
14474 |
|
14475 |
|
14476 |
|
14477 |
|
14478 |
|
14479 | function extendError (targetError, sourceError) {
|
14480 | extendStack(targetError, sourceError);
|
14481 | extend(targetError, sourceError);
|
14482 | }
|
14483 |
|
14484 |
|
14485 |
|
14486 |
|
14487 |
|
14488 |
|
14489 | function extendToJSON (error) {
|
14490 | error.toJSON = errorToJSON;
|
14491 |
|
14492 |
|
14493 | error.inspect = errorToString;
|
14494 | }
|
14495 |
|
14496 |
|
14497 |
|
14498 |
|
14499 |
|
14500 |
|
14501 |
|
14502 | function 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 |
|
14509 |
|
14510 | if (protectedProperties.indexOf(key) >= 0) {
|
14511 | continue;
|
14512 | }
|
14513 |
|
14514 | try {
|
14515 | target[key] = source[key];
|
14516 | }
|
14517 | catch (e) {
|
14518 |
|
14519 | }
|
14520 | }
|
14521 | }
|
14522 | }
|
14523 |
|
14524 |
|
14525 |
|
14526 |
|
14527 |
|
14528 |
|
14529 |
|
14530 | function errorToJSON () {
|
14531 | var json = {};
|
14532 |
|
14533 |
|
14534 | var keys = Object.keys(this);
|
14535 |
|
14536 |
|
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 |
|
14553 |
|
14554 |
|
14555 |
|
14556 | function errorToString () {
|
14557 | return JSON.stringify(this, null, 2).replace(/\\n/g, "\n");
|
14558 | }
|
14559 |
|
14560 |
|
14561 |
|
14562 |
|
14563 |
|
14564 |
|
14565 |
|
14566 | function 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 |
|
14587 |
|
14588 |
|
14589 |
|
14590 |
|
14591 |
|
14592 | function 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 |
|
14605 |
|
14606 |
|
14607 |
|
14608 |
|
14609 | function popStack (stack) {
|
14610 | if (stack) {
|
14611 | var lines = stack.split("\n");
|
14612 |
|
14613 | if (lines.length < 2) {
|
14614 |
|
14615 | return stack;
|
14616 | }
|
14617 |
|
14618 |
|
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 |
|
14628 |
|
14629 |
|
14630 | return stack;
|
14631 | }
|
14632 | }
|
14633 |
|
14634 |
|
14635 |
|
14636 |
|
14637 |
|
14638 | var supportsLazyStack = (function () {
|
14639 | return !!(
|
14640 |
|
14641 | Object.getOwnPropertyDescriptor && Object.defineProperty &&
|
14642 |
|
14643 |
|
14644 | (typeof navigator === "undefined" || !/Android/.test(navigator.userAgent))
|
14645 | );
|
14646 | }());
|
14647 |
|
14648 |
|
14649 |
|
14650 |
|
14651 |
|
14652 |
|
14653 |
|
14654 | function 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 |
|
14668 |
|
14669 |
|
14670 |
|
14671 |
|
14672 | function 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 |
|
14686 |
|
14687 |
|
14688 |
|
14689 | function 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){
|
14702 | module.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 |
|
15955 | if (!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 |
|
15963 | function 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 |
|
16002 | var process = module.exports = {};
|
16003 |
|
16004 |
|
16005 |
|
16006 |
|
16007 |
|
16008 |
|
16009 | var cachedSetTimeout;
|
16010 | var cachedClearTimeout;
|
16011 |
|
16012 | function defaultSetTimout() {
|
16013 | throw new Error('setTimeout has not been defined');
|
16014 | }
|
16015 | function 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 | } ())
|
16038 | function runTimeout(fun) {
|
16039 | if (cachedSetTimeout === setTimeout) {
|
16040 |
|
16041 | return setTimeout(fun, 0);
|
16042 | }
|
16043 |
|
16044 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
16045 | cachedSetTimeout = setTimeout;
|
16046 | return setTimeout(fun, 0);
|
16047 | }
|
16048 | try {
|
16049 |
|
16050 | return cachedSetTimeout(fun, 0);
|
16051 | } catch(e){
|
16052 | try {
|
16053 |
|
16054 | return cachedSetTimeout.call(null, fun, 0);
|
16055 | } catch(e){
|
16056 |
|
16057 | return cachedSetTimeout.call(this, fun, 0);
|
16058 | }
|
16059 | }
|
16060 |
|
16061 |
|
16062 | }
|
16063 | function runClearTimeout(marker) {
|
16064 | if (cachedClearTimeout === clearTimeout) {
|
16065 |
|
16066 | return clearTimeout(marker);
|
16067 | }
|
16068 |
|
16069 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
16070 | cachedClearTimeout = clearTimeout;
|
16071 | return clearTimeout(marker);
|
16072 | }
|
16073 | try {
|
16074 |
|
16075 | return cachedClearTimeout(marker);
|
16076 | } catch (e){
|
16077 | try {
|
16078 |
|
16079 | return cachedClearTimeout.call(null, marker);
|
16080 | } catch (e){
|
16081 |
|
16082 |
|
16083 | return cachedClearTimeout.call(this, marker);
|
16084 | }
|
16085 | }
|
16086 |
|
16087 |
|
16088 |
|
16089 | }
|
16090 | var queue = [];
|
16091 | var draining = false;
|
16092 | var currentQueue;
|
16093 | var queueIndex = -1;
|
16094 |
|
16095 | function 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 |
|
16110 | function 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 |
|
16134 | process.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 |
|
16148 | function Item(fun, array) {
|
16149 | this.fun = fun;
|
16150 | this.array = array;
|
16151 | }
|
16152 | Item.prototype.run = function () {
|
16153 | this.fun.apply(null, this.array);
|
16154 | };
|
16155 | process.title = 'browser';
|
16156 | process.browser = true;
|
16157 | process.env = {};
|
16158 | process.argv = [];
|
16159 | process.version = '';
|
16160 | process.versions = {};
|
16161 |
|
16162 | function noop() {}
|
16163 |
|
16164 | process.on = noop;
|
16165 | process.addListener = noop;
|
16166 | process.once = noop;
|
16167 | process.off = noop;
|
16168 | process.removeListener = noop;
|
16169 | process.removeAllListeners = noop;
|
16170 | process.emit = noop;
|
16171 | process.prependListener = noop;
|
16172 | process.prependOnceListener = noop;
|
16173 |
|
16174 | process.listeners = function (name) { return [] }
|
16175 |
|
16176 | process.binding = function (name) {
|
16177 | throw new Error('process.binding is not supported');
|
16178 | };
|
16179 |
|
16180 | process.cwd = function () { return '/' };
|
16181 | process.chdir = function (dir) {
|
16182 | throw new Error('process.chdir is not supported');
|
16183 | };
|
16184 | process.umask = function() { return 0; };
|
16185 |
|
16186 | },{}],126:[function(require,module,exports){
|
16187 |
|
16188 |
|
16189 |
|
16190 |
|
16191 |
|
16192 |
|
16193 |
|
16194 |
|
16195 |
|
16196 |
|
16197 |
|
16198 |
|
16199 |
|
16200 |
|
16201 |
|
16202 |
|
16203 |
|
16204 |
|
16205 |
|
16206 |
|
16207 |
|
16208 | 'use strict';
|
16209 |
|
16210 |
|
16211 |
|
16212 |
|
16213 | function hasOwnProperty(obj, prop) {
|
16214 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
16215 | }
|
16216 |
|
16217 | module.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 |
|
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 |
|
16268 | var isArray = Array.isArray || function (xs) {
|
16269 | return Object.prototype.toString.call(xs) === '[object Array]';
|
16270 | };
|
16271 |
|
16272 | },{}],127:[function(require,module,exports){
|
16273 |
|
16274 |
|
16275 |
|
16276 |
|
16277 |
|
16278 |
|
16279 |
|
16280 |
|
16281 |
|
16282 |
|
16283 |
|
16284 |
|
16285 |
|
16286 |
|
16287 |
|
16288 |
|
16289 |
|
16290 |
|
16291 |
|
16292 |
|
16293 |
|
16294 | 'use strict';
|
16295 |
|
16296 | var 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 |
|
16312 | module.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 |
|
16338 | var isArray = Array.isArray || function (xs) {
|
16339 | return Object.prototype.toString.call(xs) === '[object Array]';
|
16340 | };
|
16341 |
|
16342 | function 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 |
|
16351 | var 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 |
|
16362 | exports.decode = exports.parse = require('./decode');
|
16363 | exports.encode = exports.stringify = require('./encode');
|
16364 |
|
16365 | },{"./decode":126,"./encode":127}],129:[function(require,module,exports){
|
16366 |
|
16367 |
|
16368 |
|
16369 |
|
16370 |
|
16371 |
|
16372 |
|
16373 |
|
16374 |
|
16375 |
|
16376 |
|
16377 |
|
16378 |
|
16379 |
|
16380 |
|
16381 |
|
16382 |
|
16383 |
|
16384 |
|
16385 |
|
16386 |
|
16387 |
|
16388 |
|
16389 |
|
16390 |
|
16391 |
|
16392 | 'use strict';
|
16393 |
|
16394 |
|
16395 |
|
16396 | var pna = require('process-nextick-args');
|
16397 |
|
16398 |
|
16399 |
|
16400 | var objectKeys = Object.keys || function (obj) {
|
16401 | var keys = [];
|
16402 | for (var key in obj) {
|
16403 | keys.push(key);
|
16404 | }return keys;
|
16405 | };
|
16406 |
|
16407 |
|
16408 | module.exports = Duplex;
|
16409 |
|
16410 |
|
16411 | var util = require('core-util-is');
|
16412 | util.inherits = require('inherits');
|
16413 |
|
16414 |
|
16415 | var Readable = require('./_stream_readable');
|
16416 | var Writable = require('./_stream_writable');
|
16417 |
|
16418 | util.inherits(Duplex, Readable);
|
16419 |
|
16420 | {
|
16421 |
|
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 |
|
16429 | function 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 |
|
16445 | Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
16446 |
|
16447 |
|
16448 |
|
16449 | enumerable: false,
|
16450 | get: function () {
|
16451 | return this._writableState.highWaterMark;
|
16452 | }
|
16453 | });
|
16454 |
|
16455 |
|
16456 | function onend() {
|
16457 |
|
16458 |
|
16459 | if (this.allowHalfOpen || this._writableState.ended) return;
|
16460 |
|
16461 |
|
16462 |
|
16463 | pna.nextTick(onEndNT, this);
|
16464 | }
|
16465 |
|
16466 | function onEndNT(self) {
|
16467 | self.end();
|
16468 | }
|
16469 |
|
16470 | Object.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 |
|
16479 |
|
16480 | if (this._readableState === undefined || this._writableState === undefined) {
|
16481 | return;
|
16482 | }
|
16483 |
|
16484 |
|
16485 |
|
16486 | this._readableState.destroyed = value;
|
16487 | this._writableState.destroyed = value;
|
16488 | }
|
16489 | });
|
16490 |
|
16491 | Duplex.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 |
|
16499 |
|
16500 |
|
16501 |
|
16502 |
|
16503 |
|
16504 |
|
16505 |
|
16506 |
|
16507 |
|
16508 |
|
16509 |
|
16510 |
|
16511 |
|
16512 |
|
16513 |
|
16514 |
|
16515 |
|
16516 |
|
16517 |
|
16518 |
|
16519 |
|
16520 |
|
16521 |
|
16522 |
|
16523 | 'use strict';
|
16524 |
|
16525 | module.exports = PassThrough;
|
16526 |
|
16527 | var Transform = require('./_stream_transform');
|
16528 |
|
16529 |
|
16530 | var util = require('core-util-is');
|
16531 | util.inherits = require('inherits');
|
16532 |
|
16533 |
|
16534 | util.inherits(PassThrough, Transform);
|
16535 |
|
16536 | function PassThrough(options) {
|
16537 | if (!(this instanceof PassThrough)) return new PassThrough(options);
|
16538 |
|
16539 | Transform.call(this, options);
|
16540 | }
|
16541 |
|
16542 | PassThrough.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 |
|
16548 |
|
16549 |
|
16550 |
|
16551 |
|
16552 |
|
16553 |
|
16554 |
|
16555 |
|
16556 |
|
16557 |
|
16558 |
|
16559 |
|
16560 |
|
16561 |
|
16562 |
|
16563 |
|
16564 |
|
16565 |
|
16566 |
|
16567 |
|
16568 | 'use strict';
|
16569 |
|
16570 |
|
16571 |
|
16572 | var pna = require('process-nextick-args');
|
16573 |
|
16574 |
|
16575 | module.exports = Readable;
|
16576 |
|
16577 |
|
16578 | var isArray = require('isarray');
|
16579 |
|
16580 |
|
16581 |
|
16582 | var Duplex;
|
16583 |
|
16584 |
|
16585 | Readable.ReadableState = ReadableState;
|
16586 |
|
16587 |
|
16588 | var EE = require('events').EventEmitter;
|
16589 |
|
16590 | var EElistenerCount = function (emitter, type) {
|
16591 | return emitter.listeners(type).length;
|
16592 | };
|
16593 |
|
16594 |
|
16595 |
|
16596 | var Stream = require('./internal/streams/stream');
|
16597 |
|
16598 |
|
16599 |
|
16600 |
|
16601 | var Buffer = require('safe-buffer').Buffer;
|
16602 | var OurUint8Array = global.Uint8Array || function () {};
|
16603 | function _uint8ArrayToBuffer(chunk) {
|
16604 | return Buffer.from(chunk);
|
16605 | }
|
16606 | function _isUint8Array(obj) {
|
16607 | return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
16608 | }
|
16609 |
|
16610 |
|
16611 |
|
16612 |
|
16613 | var util = require('core-util-is');
|
16614 | util.inherits = require('inherits');
|
16615 |
|
16616 |
|
16617 |
|
16618 | var debugUtil = require('util');
|
16619 | var debug = void 0;
|
16620 | if (debugUtil && debugUtil.debuglog) {
|
16621 | debug = debugUtil.debuglog('stream');
|
16622 | } else {
|
16623 | debug = function () {};
|
16624 | }
|
16625 |
|
16626 |
|
16627 | var BufferList = require('./internal/streams/BufferList');
|
16628 | var destroyImpl = require('./internal/streams/destroy');
|
16629 | var StringDecoder;
|
16630 |
|
16631 | util.inherits(Readable, Stream);
|
16632 |
|
16633 | var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
16634 |
|
16635 | function prependListener(emitter, event, fn) {
|
16636 |
|
16637 |
|
16638 | if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
16639 |
|
16640 |
|
16641 |
|
16642 |
|
16643 |
|
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 |
|
16647 | function ReadableState(options, stream) {
|
16648 | Duplex = Duplex || require('./_stream_duplex');
|
16649 |
|
16650 | options = options || {};
|
16651 |
|
16652 |
|
16653 |
|
16654 |
|
16655 |
|
16656 |
|
16657 | var isDuplex = stream instanceof Duplex;
|
16658 |
|
16659 |
|
16660 |
|
16661 | this.objectMode = !!options.objectMode;
|
16662 |
|
16663 | if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
16664 |
|
16665 |
|
16666 |
|
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 |
|
16674 | this.highWaterMark = Math.floor(this.highWaterMark);
|
16675 |
|
16676 |
|
16677 |
|
16678 |
|
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 |
|
16689 |
|
16690 |
|
16691 |
|
16692 | this.sync = true;
|
16693 |
|
16694 |
|
16695 |
|
16696 | this.needReadable = false;
|
16697 | this.emittedReadable = false;
|
16698 | this.readableListening = false;
|
16699 | this.resumeScheduled = false;
|
16700 |
|
16701 |
|
16702 | this.destroyed = false;
|
16703 |
|
16704 |
|
16705 |
|
16706 |
|
16707 | this.defaultEncoding = options.defaultEncoding || 'utf8';
|
16708 |
|
16709 |
|
16710 | this.awaitDrain = 0;
|
16711 |
|
16712 |
|
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 |
|
16724 | function 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 |
|
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 |
|
16743 | Object.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 |
|
16752 |
|
16753 | if (!this._readableState) {
|
16754 | return;
|
16755 | }
|
16756 |
|
16757 |
|
16758 |
|
16759 | this._readableState.destroyed = value;
|
16760 | }
|
16761 | });
|
16762 |
|
16763 | Readable.prototype.destroy = destroyImpl.destroy;
|
16764 | Readable.prototype._undestroy = destroyImpl.undestroy;
|
16765 | Readable.prototype._destroy = function (err, cb) {
|
16766 | this.push(null);
|
16767 | cb(err);
|
16768 | };
|
16769 |
|
16770 |
|
16771 |
|
16772 |
|
16773 |
|
16774 | Readable.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 |
|
16795 | Readable.prototype.unshift = function (chunk) {
|
16796 | return readableAddChunk(this, chunk, null, true, false);
|
16797 | };
|
16798 |
|
16799 | function 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 |
|
16835 | function 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 |
|
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 |
|
16849 | function 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 |
|
16858 |
|
16859 |
|
16860 |
|
16861 |
|
16862 |
|
16863 |
|
16864 | function needMoreData(state) {
|
16865 | return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
16866 | }
|
16867 |
|
16868 | Readable.prototype.isPaused = function () {
|
16869 | return this._readableState.flowing === false;
|
16870 | };
|
16871 |
|
16872 |
|
16873 | Readable.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 |
|
16881 | var MAX_HWM = 0x800000;
|
16882 | function computeNewHighWaterMark(n) {
|
16883 | if (n >= MAX_HWM) {
|
16884 | n = MAX_HWM;
|
16885 | } else {
|
16886 |
|
16887 |
|
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 |
|
16900 |
|
16901 | function 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 |
|
16906 | if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
16907 | }
|
16908 |
|
16909 | if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
16910 | if (n <= state.length) return n;
|
16911 |
|
16912 | if (!state.ended) {
|
16913 | state.needReadable = true;
|
16914 | return 0;
|
16915 | }
|
16916 | return state.length;
|
16917 | }
|
16918 |
|
16919 |
|
16920 | Readable.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 |
|
16929 |
|
16930 |
|
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 |
|
16940 | if (n === 0 && state.ended) {
|
16941 | if (state.length === 0) endReadable(this);
|
16942 | return null;
|
16943 | }
|
16944 |
|
16945 |
|
16946 |
|
16947 |
|
16948 |
|
16949 |
|
16950 |
|
16951 |
|
16952 |
|
16953 |
|
16954 |
|
16955 |
|
16956 |
|
16957 |
|
16958 |
|
16959 |
|
16960 |
|
16961 |
|
16962 |
|
16963 |
|
16964 |
|
16965 |
|
16966 |
|
16967 |
|
16968 | var doRead = state.needReadable;
|
16969 | debug('need readable', doRead);
|
16970 |
|
16971 |
|
16972 | if (state.length === 0 || state.length - n < state.highWaterMark) {
|
16973 | doRead = true;
|
16974 | debug('length less than watermark', doRead);
|
16975 | }
|
16976 |
|
16977 |
|
16978 |
|
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 |
|
16987 | if (state.length === 0) state.needReadable = true;
|
16988 |
|
16989 | this._read(state.highWaterMark);
|
16990 | state.sync = false;
|
16991 |
|
16992 |
|
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 |
|
17008 |
|
17009 | if (!state.ended) state.needReadable = true;
|
17010 |
|
17011 |
|
17012 | if (nOrig !== n && state.ended) endReadable(this);
|
17013 | }
|
17014 |
|
17015 | if (ret !== null) this.emit('data', ret);
|
17016 |
|
17017 | return ret;
|
17018 | };
|
17019 |
|
17020 | function 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 |
|
17032 | emitReadable(stream);
|
17033 | }
|
17034 |
|
17035 |
|
17036 |
|
17037 |
|
17038 | function 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 |
|
17048 | function emitReadable_(stream) {
|
17049 | debug('emit readable');
|
17050 | stream.emit('readable');
|
17051 | flow(stream);
|
17052 | }
|
17053 |
|
17054 |
|
17055 |
|
17056 |
|
17057 |
|
17058 |
|
17059 |
|
17060 | function maybeReadMore(stream, state) {
|
17061 | if (!state.readingMore) {
|
17062 | state.readingMore = true;
|
17063 | pna.nextTick(maybeReadMore_, stream, state);
|
17064 | }
|
17065 | }
|
17066 |
|
17067 | function 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 |
|
17074 | break;else len = state.length;
|
17075 | }
|
17076 | state.readingMore = false;
|
17077 | }
|
17078 |
|
17079 |
|
17080 |
|
17081 |
|
17082 |
|
17083 | Readable.prototype._read = function (n) {
|
17084 | this.emit('error', new Error('_read() is not implemented'));
|
17085 | };
|
17086 |
|
17087 | Readable.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 |
|
17127 |
|
17128 |
|
17129 |
|
17130 | var ondrain = pipeOnDrain(src);
|
17131 | dest.on('drain', ondrain);
|
17132 |
|
17133 | var cleanedUp = false;
|
17134 | function cleanup() {
|
17135 | debug('cleanup');
|
17136 |
|
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 |
|
17149 |
|
17150 |
|
17151 |
|
17152 |
|
17153 | if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
17154 | }
|
17155 |
|
17156 |
|
17157 |
|
17158 |
|
17159 |
|
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 |
|
17168 |
|
17169 |
|
17170 |
|
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 |
|
17181 |
|
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 |
|
17190 | prependListener(dest, 'error', onerror);
|
17191 |
|
17192 |
|
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 |
|
17211 | dest.emit('pipe', src);
|
17212 |
|
17213 |
|
17214 | if (!state.flowing) {
|
17215 | debug('pipe resume');
|
17216 | src.resume();
|
17217 | }
|
17218 |
|
17219 | return dest;
|
17220 | };
|
17221 |
|
17222 | function 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 |
|
17234 | Readable.prototype.unpipe = function (dest) {
|
17235 | var state = this._readableState;
|
17236 | var unpipeInfo = { hasUnpiped: false };
|
17237 |
|
17238 |
|
17239 | if (state.pipesCount === 0) return this;
|
17240 |
|
17241 |
|
17242 | if (state.pipesCount === 1) {
|
17243 |
|
17244 | if (dest && dest !== state.pipes) return this;
|
17245 |
|
17246 | if (!dest) dest = state.pipes;
|
17247 |
|
17248 |
|
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 |
|
17257 |
|
17258 | if (!dest) {
|
17259 |
|
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 |
|
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 |
|
17285 |
|
17286 | Readable.prototype.on = function (ev, fn) {
|
17287 | var res = Stream.prototype.on.call(this, ev, fn);
|
17288 |
|
17289 | if (ev === 'data') {
|
17290 |
|
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 | };
|
17307 | Readable.prototype.addListener = Readable.prototype.on;
|
17308 |
|
17309 | function nReadingNextTick(self) {
|
17310 | debug('readable nexttick read 0');
|
17311 | self.read(0);
|
17312 | }
|
17313 |
|
17314 |
|
17315 |
|
17316 | Readable.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 |
|
17326 | function resume(stream, state) {
|
17327 | if (!state.resumeScheduled) {
|
17328 | state.resumeScheduled = true;
|
17329 | pna.nextTick(resume_, stream, state);
|
17330 | }
|
17331 | }
|
17332 |
|
17333 | function 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 |
|
17346 | Readable.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 |
|
17356 | function flow(stream) {
|
17357 | var state = stream._readableState;
|
17358 | debug('flow', state.flowing);
|
17359 | while (state.flowing && stream.read() !== null) {}
|
17360 | }
|
17361 |
|
17362 |
|
17363 |
|
17364 |
|
17365 | Readable.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 |
|
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 |
|
17396 |
|
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 |
|
17408 | for (var n = 0; n < kProxyEvents.length; n++) {
|
17409 | stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
17410 | }
|
17411 |
|
17412 |
|
17413 |
|
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 |
|
17425 | Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
17426 |
|
17427 |
|
17428 |
|
17429 | enumerable: false,
|
17430 | get: function () {
|
17431 | return this._readableState.highWaterMark;
|
17432 | }
|
17433 | });
|
17434 |
|
17435 |
|
17436 | Readable._fromList = fromList;
|
17437 |
|
17438 |
|
17439 |
|
17440 |
|
17441 |
|
17442 | function fromList(n, state) {
|
17443 |
|
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 |
|
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 |
|
17453 | ret = fromListPartial(n, state.buffer, state.decoder);
|
17454 | }
|
17455 |
|
17456 | return ret;
|
17457 | }
|
17458 |
|
17459 |
|
17460 |
|
17461 |
|
17462 | function fromListPartial(n, list, hasStrings) {
|
17463 | var ret;
|
17464 | if (n < list.head.data.length) {
|
17465 |
|
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 |
|
17470 | ret = list.shift();
|
17471 | } else {
|
17472 |
|
17473 | ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
17474 | }
|
17475 | return ret;
|
17476 | }
|
17477 |
|
17478 |
|
17479 |
|
17480 |
|
17481 |
|
17482 | function 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 |
|
17509 |
|
17510 |
|
17511 | function 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 |
|
17538 | function endReadable(stream) {
|
17539 | var state = stream._readableState;
|
17540 |
|
17541 |
|
17542 |
|
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 |
|
17551 | function endReadableNT(state, stream) {
|
17552 |
|
17553 | if (!state.endEmitted && state.length === 0) {
|
17554 | state.endEmitted = true;
|
17555 | stream.readable = false;
|
17556 | stream.emit('end');
|
17557 | }
|
17558 | }
|
17559 |
|
17560 | function 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 |
|
17570 |
|
17571 |
|
17572 |
|
17573 |
|
17574 |
|
17575 |
|
17576 |
|
17577 |
|
17578 |
|
17579 |
|
17580 |
|
17581 |
|
17582 |
|
17583 |
|
17584 |
|
17585 |
|
17586 |
|
17587 |
|
17588 |
|
17589 |
|
17590 |
|
17591 |
|
17592 |
|
17593 |
|
17594 |
|
17595 |
|
17596 |
|
17597 |
|
17598 |
|
17599 |
|
17600 |
|
17601 |
|
17602 |
|
17603 |
|
17604 |
|
17605 |
|
17606 |
|
17607 |
|
17608 |
|
17609 |
|
17610 |
|
17611 |
|
17612 |
|
17613 |
|
17614 |
|
17615 |
|
17616 |
|
17617 |
|
17618 |
|
17619 |
|
17620 |
|
17621 |
|
17622 |
|
17623 |
|
17624 |
|
17625 |
|
17626 |
|
17627 |
|
17628 |
|
17629 |
|
17630 |
|
17631 |
|
17632 | 'use strict';
|
17633 |
|
17634 | module.exports = Transform;
|
17635 |
|
17636 | var Duplex = require('./_stream_duplex');
|
17637 |
|
17638 |
|
17639 | var util = require('core-util-is');
|
17640 | util.inherits = require('inherits');
|
17641 |
|
17642 |
|
17643 | util.inherits(Transform, Duplex);
|
17644 |
|
17645 | function 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)
|
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 |
|
17670 | function 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 |
|
17685 | this._readableState.needReadable = true;
|
17686 |
|
17687 |
|
17688 |
|
17689 |
|
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 |
|
17699 | this.on('prefinish', prefinish);
|
17700 | }
|
17701 |
|
17702 | function 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 |
|
17714 | Transform.prototype.push = function (chunk, encoding) {
|
17715 | this._transformState.needTransform = false;
|
17716 | return Duplex.prototype.push.call(this, chunk, encoding);
|
17717 | };
|
17718 |
|
17719 |
|
17720 |
|
17721 |
|
17722 |
|
17723 |
|
17724 |
|
17725 |
|
17726 |
|
17727 |
|
17728 |
|
17729 | Transform.prototype._transform = function (chunk, encoding, cb) {
|
17730 | throw new Error('_transform() is not implemented');
|
17731 | };
|
17732 |
|
17733 | Transform.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 |
|
17745 |
|
17746 |
|
17747 | Transform.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 |
|
17755 |
|
17756 | ts.needTransform = true;
|
17757 | }
|
17758 | };
|
17759 |
|
17760 | Transform.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 |
|
17769 | function done(stream, er, data) {
|
17770 | if (er) return stream.emit('error', er);
|
17771 |
|
17772 | if (data != null)
|
17773 | stream.push(data);
|
17774 |
|
17775 |
|
17776 |
|
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 |
|
17786 |
|
17787 |
|
17788 |
|
17789 |
|
17790 |
|
17791 |
|
17792 |
|
17793 |
|
17794 |
|
17795 |
|
17796 |
|
17797 |
|
17798 |
|
17799 |
|
17800 |
|
17801 |
|
17802 |
|
17803 |
|
17804 |
|
17805 |
|
17806 |
|
17807 |
|
17808 |
|
17809 |
|
17810 | 'use strict';
|
17811 |
|
17812 |
|
17813 |
|
17814 | var pna = require('process-nextick-args');
|
17815 |
|
17816 |
|
17817 | module.exports = Writable;
|
17818 |
|
17819 |
|
17820 | function WriteReq(chunk, encoding, cb) {
|
17821 | this.chunk = chunk;
|
17822 | this.encoding = encoding;
|
17823 | this.callback = cb;
|
17824 | this.next = null;
|
17825 | }
|
17826 |
|
17827 |
|
17828 |
|
17829 | function 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 |
|
17839 |
|
17840 |
|
17841 | var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
17842 |
|
17843 |
|
17844 |
|
17845 | var Duplex;
|
17846 |
|
17847 |
|
17848 | Writable.WritableState = WritableState;
|
17849 |
|
17850 |
|
17851 | var util = require('core-util-is');
|
17852 | util.inherits = require('inherits');
|
17853 |
|
17854 |
|
17855 |
|
17856 | var internalUtil = {
|
17857 | deprecate: require('util-deprecate')
|
17858 | };
|
17859 |
|
17860 |
|
17861 |
|
17862 | var Stream = require('./internal/streams/stream');
|
17863 |
|
17864 |
|
17865 |
|
17866 |
|
17867 | var Buffer = require('safe-buffer').Buffer;
|
17868 | var OurUint8Array = global.Uint8Array || function () {};
|
17869 | function _uint8ArrayToBuffer(chunk) {
|
17870 | return Buffer.from(chunk);
|
17871 | }
|
17872 | function _isUint8Array(obj) {
|
17873 | return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
17874 | }
|
17875 |
|
17876 |
|
17877 |
|
17878 | var destroyImpl = require('./internal/streams/destroy');
|
17879 |
|
17880 | util.inherits(Writable, Stream);
|
17881 |
|
17882 | function nop() {}
|
17883 |
|
17884 | function WritableState(options, stream) {
|
17885 | Duplex = Duplex || require('./_stream_duplex');
|
17886 |
|
17887 | options = options || {};
|
17888 |
|
17889 |
|
17890 |
|
17891 |
|
17892 |
|
17893 |
|
17894 | var isDuplex = stream instanceof Duplex;
|
17895 |
|
17896 |
|
17897 |
|
17898 | this.objectMode = !!options.objectMode;
|
17899 |
|
17900 | if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
17901 |
|
17902 |
|
17903 |
|
17904 |
|
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 |
|
17912 | this.highWaterMark = Math.floor(this.highWaterMark);
|
17913 |
|
17914 |
|
17915 | this.finalCalled = false;
|
17916 |
|
17917 |
|
17918 | this.needDrain = false;
|
17919 |
|
17920 | this.ending = false;
|
17921 |
|
17922 | this.ended = false;
|
17923 |
|
17924 | this.finished = false;
|
17925 |
|
17926 |
|
17927 | this.destroyed = false;
|
17928 |
|
17929 |
|
17930 |
|
17931 |
|
17932 | var noDecode = options.decodeStrings === false;
|
17933 | this.decodeStrings = !noDecode;
|
17934 |
|
17935 |
|
17936 |
|
17937 |
|
17938 | this.defaultEncoding = options.defaultEncoding || 'utf8';
|
17939 |
|
17940 |
|
17941 |
|
17942 |
|
17943 | this.length = 0;
|
17944 |
|
17945 |
|
17946 | this.writing = false;
|
17947 |
|
17948 |
|
17949 | this.corked = 0;
|
17950 |
|
17951 |
|
17952 |
|
17953 |
|
17954 |
|
17955 | this.sync = true;
|
17956 |
|
17957 |
|
17958 |
|
17959 |
|
17960 | this.bufferProcessing = false;
|
17961 |
|
17962 |
|
17963 | this.onwrite = function (er) {
|
17964 | onwrite(stream, er);
|
17965 | };
|
17966 |
|
17967 |
|
17968 | this.writecb = null;
|
17969 |
|
17970 |
|
17971 | this.writelen = 0;
|
17972 |
|
17973 | this.bufferedRequest = null;
|
17974 | this.lastBufferedRequest = null;
|
17975 |
|
17976 |
|
17977 |
|
17978 | this.pendingcb = 0;
|
17979 |
|
17980 |
|
17981 |
|
17982 | this.prefinished = false;
|
17983 |
|
17984 |
|
17985 | this.errorEmitted = false;
|
17986 |
|
17987 |
|
17988 | this.bufferedRequestCount = 0;
|
17989 |
|
17990 |
|
17991 |
|
17992 | this.corkedRequestsFree = new CorkedRequest(this);
|
17993 | }
|
17994 |
|
17995 | WritableState.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 |
|
18016 |
|
18017 | var realHasInstance;
|
18018 | if (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 |
|
18034 | function Writable(options) {
|
18035 | Duplex = Duplex || require('./_stream_duplex');
|
18036 |
|
18037 |
|
18038 |
|
18039 |
|
18040 |
|
18041 |
|
18042 |
|
18043 |
|
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 |
|
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 |
|
18067 | Writable.prototype.pipe = function () {
|
18068 | this.emit('error', new Error('Cannot pipe, not readable'));
|
18069 | };
|
18070 |
|
18071 | function writeAfterEnd(stream, cb) {
|
18072 | var er = new Error('write after end');
|
18073 |
|
18074 | stream.emit('error', er);
|
18075 | pna.nextTick(cb, er);
|
18076 | }
|
18077 |
|
18078 |
|
18079 |
|
18080 |
|
18081 | function 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 |
|
18098 | Writable.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 |
|
18124 | Writable.prototype.cork = function () {
|
18125 | var state = this._writableState;
|
18126 |
|
18127 | state.corked++;
|
18128 | };
|
18129 |
|
18130 | Writable.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 |
|
18140 | Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
18141 |
|
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 |
|
18148 | function 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 |
|
18155 | Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
18156 |
|
18157 |
|
18158 |
|
18159 | enumerable: false,
|
18160 | get: function () {
|
18161 | return this._writableState.highWaterMark;
|
18162 | }
|
18163 | });
|
18164 |
|
18165 |
|
18166 |
|
18167 |
|
18168 | function 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 |
|
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 |
|
18207 | function 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 |
|
18216 | function onwriteError(stream, state, sync, er, cb) {
|
18217 | --state.pendingcb;
|
18218 |
|
18219 | if (sync) {
|
18220 |
|
18221 |
|
18222 | pna.nextTick(cb, er);
|
18223 |
|
18224 |
|
18225 | pna.nextTick(finishMaybe, stream, state);
|
18226 | stream._writableState.errorEmitted = true;
|
18227 | stream.emit('error', er);
|
18228 | } else {
|
18229 |
|
18230 |
|
18231 | cb(er);
|
18232 | stream._writableState.errorEmitted = true;
|
18233 | stream.emit('error', er);
|
18234 |
|
18235 |
|
18236 | finishMaybe(stream, state);
|
18237 | }
|
18238 | }
|
18239 |
|
18240 | function onwriteStateUpdate(state) {
|
18241 | state.writing = false;
|
18242 | state.writecb = null;
|
18243 | state.length -= state.writelen;
|
18244 | state.writelen = 0;
|
18245 | }
|
18246 |
|
18247 | function 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 |
|
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 |
|
18264 | asyncWrite(afterWrite, stream, state, finished, cb);
|
18265 |
|
18266 | } else {
|
18267 | afterWrite(stream, state, finished, cb);
|
18268 | }
|
18269 | }
|
18270 | }
|
18271 |
|
18272 | function afterWrite(stream, state, finished, cb) {
|
18273 | if (!finished) onwriteDrain(stream, state);
|
18274 | state.pendingcb--;
|
18275 | cb();
|
18276 | finishMaybe(stream, state);
|
18277 | }
|
18278 |
|
18279 |
|
18280 |
|
18281 |
|
18282 | function onwriteDrain(stream, state) {
|
18283 | if (state.length === 0 && state.needDrain) {
|
18284 | state.needDrain = false;
|
18285 | stream.emit('drain');
|
18286 | }
|
18287 | }
|
18288 |
|
18289 |
|
18290 | function clearBuffer(stream, state) {
|
18291 | state.bufferProcessing = true;
|
18292 | var entry = state.bufferedRequest;
|
18293 |
|
18294 | if (stream._writev && entry && entry.next) {
|
18295 |
|
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 |
|
18314 |
|
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 |
|
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 |
|
18336 |
|
18337 |
|
18338 |
|
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 |
|
18351 | Writable.prototype._write = function (chunk, encoding, cb) {
|
18352 | cb(new Error('_write() is not implemented'));
|
18353 | };
|
18354 |
|
18355 | Writable.prototype._writev = null;
|
18356 |
|
18357 | Writable.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 |
|
18372 | if (state.corked) {
|
18373 | state.corked = 1;
|
18374 | this.uncork();
|
18375 | }
|
18376 |
|
18377 |
|
18378 | if (!state.ending && !state.finished) endWritable(this, state, cb);
|
18379 | };
|
18380 |
|
18381 | function needFinish(state) {
|
18382 | return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
18383 | }
|
18384 | function 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 | }
|
18395 | function 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 |
|
18408 | function 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 |
|
18420 | function 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 |
|
18430 | function 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 |
|
18446 | Object.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 |
|
18455 |
|
18456 | if (!this._writableState) {
|
18457 | return;
|
18458 | }
|
18459 |
|
18460 |
|
18461 |
|
18462 | this._writableState.destroyed = value;
|
18463 | }
|
18464 | });
|
18465 |
|
18466 | Writable.prototype.destroy = destroyImpl.destroy;
|
18467 | Writable.prototype._undestroy = destroyImpl.undestroy;
|
18468 | Writable.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 |
|
18477 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18478 |
|
18479 | var Buffer = require('safe-buffer').Buffer;
|
18480 | var util = require('util');
|
18481 |
|
18482 | function copyBuffer(src, target, offset) {
|
18483 | src.copy(target, offset);
|
18484 | }
|
18485 |
|
18486 | module.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 |
|
18548 | if (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 |
|
18558 |
|
18559 | var pna = require('process-nextick-args');
|
18560 |
|
18561 |
|
18562 |
|
18563 | function 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 |
|
18579 |
|
18580 |
|
18581 | if (this._readableState) {
|
18582 | this._readableState.destroyed = true;
|
18583 | }
|
18584 |
|
18585 |
|
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 |
|
18604 | function 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 |
|
18621 | function emitErrorNT(self, err) {
|
18622 | self.emit('error', err);
|
18623 | }
|
18624 |
|
18625 | module.exports = {
|
18626 | destroy: destroy,
|
18627 | undestroy: undestroy
|
18628 | };
|
18629 | },{"process-nextick-args":124}],136:[function(require,module,exports){
|
18630 | module.exports = require('events').EventEmitter;
|
18631 |
|
18632 | },{"events":64}],137:[function(require,module,exports){
|
18633 | exports = module.exports = require('./lib/_stream_readable.js');
|
18634 | exports.Stream = exports;
|
18635 | exports.Readable = exports;
|
18636 | exports.Writable = require('./lib/_stream_writable.js');
|
18637 | exports.Duplex = require('./lib/_stream_duplex.js');
|
18638 | exports.Transform = require('./lib/_stream_transform.js');
|
18639 | exports.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 |
|
18643 | var buffer = require('buffer')
|
18644 | var Buffer = buffer.Buffer
|
18645 |
|
18646 |
|
18647 | function copyProps (src, dst) {
|
18648 | for (var key in src) {
|
18649 | dst[key] = src[key]
|
18650 | }
|
18651 | }
|
18652 | if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
18653 | module.exports = buffer
|
18654 | } else {
|
18655 |
|
18656 | copyProps(buffer, exports)
|
18657 | exports.Buffer = SafeBuffer
|
18658 | }
|
18659 |
|
18660 | function SafeBuffer (arg, encodingOrOffset, length) {
|
18661 | return Buffer(arg, encodingOrOffset, length)
|
18662 | }
|
18663 |
|
18664 |
|
18665 | copyProps(Buffer, SafeBuffer)
|
18666 |
|
18667 | SafeBuffer.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 |
|
18674 | SafeBuffer.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 |
|
18691 | SafeBuffer.allocUnsafe = function (size) {
|
18692 | if (typeof size !== 'number') {
|
18693 | throw new TypeError('Argument must be a number')
|
18694 | }
|
18695 | return Buffer(size)
|
18696 | }
|
18697 |
|
18698 | SafeBuffer.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){
|
18707 | var ClientRequest = require('./lib/request')
|
18708 | var response = require('./lib/response')
|
18709 | var extend = require('xtend')
|
18710 | var statusCodes = require('builtin-status-codes')
|
18711 | var url = require('url')
|
18712 |
|
18713 | var http = exports
|
18714 |
|
18715 | http.request = function (opts, cb) {
|
18716 | if (typeof opts === 'string')
|
18717 | opts = url.parse(opts)
|
18718 | else
|
18719 | opts = extend(opts)
|
18720 |
|
18721 |
|
18722 |
|
18723 |
|
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 |
|
18732 | if (host && host.indexOf(':') !== -1)
|
18733 | host = '[' + host + ']'
|
18734 |
|
18735 |
|
18736 | opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
|
18737 | opts.method = (opts.method || 'GET').toUpperCase()
|
18738 | opts.headers = opts.headers || {}
|
18739 |
|
18740 |
|
18741 |
|
18742 | var req = new ClientRequest(opts)
|
18743 | if (cb)
|
18744 | req.on('response', cb)
|
18745 | return req
|
18746 | }
|
18747 |
|
18748 | http.get = function get (opts, cb) {
|
18749 | var req = http.request(opts, cb)
|
18750 | req.end()
|
18751 | return req
|
18752 | }
|
18753 |
|
18754 | http.ClientRequest = ClientRequest
|
18755 | http.IncomingMessage = response.IncomingMessage
|
18756 |
|
18757 | http.Agent = function () {}
|
18758 | http.Agent.defaultMaxSockets = 4
|
18759 |
|
18760 | http.globalAgent = new http.Agent()
|
18761 |
|
18762 | http.STATUS_CODES = statusCodes
|
18763 |
|
18764 | http.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){
|
18796 | exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
|
18797 |
|
18798 | exports.writableStream = isFunction(global.WritableStream)
|
18799 |
|
18800 | exports.abortController = isFunction(global.AbortController)
|
18801 |
|
18802 | exports.blobConstructor = false
|
18803 | try {
|
18804 | new Blob([new ArrayBuffer(1)])
|
18805 | exports.blobConstructor = true
|
18806 | } catch (e) {}
|
18807 |
|
18808 |
|
18809 |
|
18810 |
|
18811 | var xhr
|
18812 | function getXHR () {
|
18813 |
|
18814 | if (xhr !== undefined) return xhr
|
18815 |
|
18816 | if (global.XMLHttpRequest) {
|
18817 | xhr = new global.XMLHttpRequest()
|
18818 |
|
18819 |
|
18820 |
|
18821 | try {
|
18822 | xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
|
18823 | } catch(e) {
|
18824 | xhr = null
|
18825 | }
|
18826 | } else {
|
18827 |
|
18828 | xhr = null
|
18829 | }
|
18830 | return xhr
|
18831 | }
|
18832 |
|
18833 | function 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 |
|
18844 |
|
18845 | var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
|
18846 | var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
|
18847 |
|
18848 |
|
18849 |
|
18850 | exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'))
|
18851 |
|
18852 |
|
18853 |
|
18854 | exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
|
18855 | exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
|
18856 | checkTypeSupport('moz-chunked-arraybuffer')
|
18857 |
|
18858 |
|
18859 |
|
18860 | exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
|
18861 |
|
18862 | exports.vbArray = isFunction(global.VBArray)
|
18863 |
|
18864 | function isFunction (value) {
|
18865 | return typeof value === 'function'
|
18866 | }
|
18867 |
|
18868 | xhr = null
|
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){
|
18874 | var capability = require('./capability')
|
18875 | var inherits = require('inherits')
|
18876 | var response = require('./response')
|
18877 | var stream = require('readable-stream')
|
18878 | var toArrayBuffer = require('to-arraybuffer')
|
18879 |
|
18880 | var IncomingMessage = response.IncomingMessage
|
18881 | var rStates = response.readyStates
|
18882 |
|
18883 | function 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 |
|
18899 | var 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 |
|
18916 | useFetch = false
|
18917 | preferBinary = true
|
18918 | } else if (opts.mode === 'prefer-streaming') {
|
18919 |
|
18920 |
|
18921 | preferBinary = false
|
18922 | } else if (opts.mode === 'allow-wrong-content-type') {
|
18923 |
|
18924 | preferBinary = !capability.overrideMimeType
|
18925 | } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
|
18926 |
|
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 |
|
18939 | inherits(ClientRequest, stream.Writable)
|
18940 |
|
18941 | ClientRequest.prototype.setHeader = function (name, value) {
|
18942 | var self = this
|
18943 | var lowerName = name.toLowerCase()
|
18944 |
|
18945 |
|
18946 |
|
18947 | if (unsafeHeaders.indexOf(lowerName) !== -1)
|
18948 | return
|
18949 |
|
18950 | self._headers[lowerName] = {
|
18951 | name: name,
|
18952 | value: value
|
18953 | }
|
18954 | }
|
18955 |
|
18956 | ClientRequest.prototype.getHeader = function (name) {
|
18957 | var header = this._headers[name.toLowerCase()]
|
18958 | if (header)
|
18959 | return header.value
|
18960 | return null
|
18961 | }
|
18962 |
|
18963 | ClientRequest.prototype.removeHeader = function (name) {
|
18964 | var self = this
|
18965 | delete self._headers[name.toLowerCase()]
|
18966 | }
|
18967 |
|
18968 | ClientRequest.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 |
|
18988 | body = Buffer.concat(self._body).toString()
|
18989 | }
|
18990 | }
|
18991 |
|
18992 |
|
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 |
|
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 |
|
19080 |
|
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 |
|
19106 |
|
19107 |
|
19108 |
|
19109 | function statusValid (xhr) {
|
19110 | try {
|
19111 | var status = xhr.status
|
19112 | return (status !== null && status !== 0)
|
19113 | } catch (e) {
|
19114 | return false
|
19115 | }
|
19116 | }
|
19117 |
|
19118 | ClientRequest.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 |
|
19130 | ClientRequest.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 |
|
19144 | ClientRequest.prototype._write = function (chunk, encoding, cb) {
|
19145 | var self = this
|
19146 |
|
19147 | self._body.push(chunk)
|
19148 | cb()
|
19149 | }
|
19150 |
|
19151 | ClientRequest.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 |
|
19163 | ClientRequest.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 |
|
19173 | ClientRequest.prototype.flushHeaders = function () {}
|
19174 | ClientRequest.prototype.setTimeout = function () {}
|
19175 | ClientRequest.prototype.setNoDelay = function () {}
|
19176 | ClientRequest.prototype.setSocketKeepAlive = function () {}
|
19177 |
|
19178 |
|
19179 | var 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){
|
19206 | var capability = require('./capability')
|
19207 | var inherits = require('inherits')
|
19208 | var stream = require('readable-stream')
|
19209 |
|
19210 | var rStates = exports.readyStates = {
|
19211 | UNSENT: 0,
|
19212 | OPENED: 1,
|
19213 | HEADERS_RECEIVED: 2,
|
19214 | LOADING: 3,
|
19215 | DONE: 4
|
19216 | }
|
19217 |
|
19218 | var 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 |
|
19229 | self.on('end', function () {
|
19230 |
|
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) {}
|
19280 | }
|
19281 |
|
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'
|
19338 | }
|
19339 | }
|
19340 | }
|
19341 |
|
19342 | inherits(IncomingMessage, stream.Readable)
|
19343 |
|
19344 | IncomingMessage.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 |
|
19354 | IncomingMessage.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':
|
19362 | if (xhr.readyState !== rStates.DONE)
|
19363 | break
|
19364 | try {
|
19365 |
|
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 |
|
19373 | case 'text':
|
19374 | try {
|
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':
|
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 |
|
19421 | reader.readAsArrayBuffer(response)
|
19422 | break
|
19423 | }
|
19424 |
|
19425 |
|
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 |
|
19435 |
|
19436 |
|
19437 |
|
19438 |
|
19439 |
|
19440 |
|
19441 |
|
19442 |
|
19443 |
|
19444 |
|
19445 |
|
19446 |
|
19447 |
|
19448 |
|
19449 |
|
19450 |
|
19451 |
|
19452 |
|
19453 |
|
19454 |
|
19455 | 'use strict';
|
19456 |
|
19457 |
|
19458 |
|
19459 | var Buffer = require('safe-buffer').Buffer;
|
19460 |
|
19461 |
|
19462 | var 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 |
|
19472 | function _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;
|
19494 | enc = ('' + enc).toLowerCase();
|
19495 | retried = true;
|
19496 | }
|
19497 | }
|
19498 | };
|
19499 |
|
19500 |
|
19501 |
|
19502 | function 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 |
|
19509 |
|
19510 |
|
19511 | exports.StringDecoder = StringDecoder;
|
19512 | function 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 |
|
19540 | StringDecoder.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 |
|
19556 | StringDecoder.prototype.end = utf8End;
|
19557 |
|
19558 |
|
19559 | StringDecoder.prototype.text = utf8Text;
|
19560 |
|
19561 |
|
19562 | StringDecoder.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 |
|
19572 |
|
19573 | function 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 |
|
19579 |
|
19580 |
|
19581 | function 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 |
|
19607 |
|
19608 |
|
19609 |
|
19610 |
|
19611 |
|
19612 |
|
19613 |
|
19614 | function 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 |
|
19634 | function 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 |
|
19647 |
|
19648 |
|
19649 | function 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 |
|
19659 |
|
19660 | function utf8End(buf) {
|
19661 | var r = buf && buf.length ? this.write(buf) : '';
|
19662 | if (this.lastNeed) return r + '\ufffd';
|
19663 | return r;
|
19664 | }
|
19665 |
|
19666 |
|
19667 |
|
19668 |
|
19669 |
|
19670 | function 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 |
|
19692 |
|
19693 | function 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 |
|
19702 | function 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 |
|
19716 | function 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 |
|
19723 | function simpleWrite(buf) {
|
19724 | return buf.toString(this.encoding);
|
19725 | }
|
19726 |
|
19727 | function simpleEnd(buf) {
|
19728 | return buf && buf.length ? this.write(buf) : '';
|
19729 | }
|
19730 | },{"safe-buffer":138}],144:[function(require,module,exports){
|
19731 | "use strict";
|
19732 |
|
19733 | module.exports = [
|
19734 | "get", "put", "post", "delete", "options", "head", "patch"
|
19735 | ];
|
19736 |
|
19737 | },{}],145:[function(require,module,exports){
|
19738 | module.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){
|
21331 | var nextTick = require('process/browser.js').nextTick;
|
21332 | var apply = Function.prototype.apply;
|
21333 | var slice = Array.prototype.slice;
|
21334 | var immediateIds = {};
|
21335 | var nextImmediateId = 0;
|
21336 |
|
21337 |
|
21338 |
|
21339 | exports.setTimeout = function() {
|
21340 | return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
|
21341 | };
|
21342 | exports.setInterval = function() {
|
21343 | return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
|
21344 | };
|
21345 | exports.clearTimeout =
|
21346 | exports.clearInterval = function(timeout) { timeout.close(); };
|
21347 |
|
21348 | function Timeout(id, clearFn) {
|
21349 | this._id = id;
|
21350 | this._clearFn = clearFn;
|
21351 | }
|
21352 | Timeout.prototype.unref = Timeout.prototype.ref = function() {};
|
21353 | Timeout.prototype.close = function() {
|
21354 | this._clearFn.call(window, this._id);
|
21355 | };
|
21356 |
|
21357 |
|
21358 | exports.enroll = function(item, msecs) {
|
21359 | clearTimeout(item._idleTimeoutId);
|
21360 | item._idleTimeout = msecs;
|
21361 | };
|
21362 |
|
21363 | exports.unenroll = function(item) {
|
21364 | clearTimeout(item._idleTimeoutId);
|
21365 | item._idleTimeout = -1;
|
21366 | };
|
21367 |
|
21368 | exports._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 |
|
21381 | exports.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 |
|
21390 |
|
21391 | if (args) {
|
21392 | fn.apply(null, args);
|
21393 | } else {
|
21394 | fn.call(null);
|
21395 | }
|
21396 |
|
21397 | exports.clearImmediate(id);
|
21398 | }
|
21399 | });
|
21400 |
|
21401 | return id;
|
21402 | };
|
21403 |
|
21404 | exports.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){
|
21410 | var Buffer = require('buffer').Buffer
|
21411 |
|
21412 | module.exports = function (buf) {
|
21413 |
|
21414 | if (buf instanceof Uint8Array) {
|
21415 |
|
21416 | if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
21417 | return buf.buffer
|
21418 | } else if (typeof buf.buffer.slice === 'function') {
|
21419 |
|
21420 | return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
|
21421 | }
|
21422 | }
|
21423 |
|
21424 | if (Buffer.isBuffer(buf)) {
|
21425 |
|
21426 |
|
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 |
|
21440 |
|
21441 |
|
21442 |
|
21443 |
|
21444 |
|
21445 |
|
21446 |
|
21447 |
|
21448 |
|
21449 |
|
21450 |
|
21451 |
|
21452 |
|
21453 |
|
21454 |
|
21455 |
|
21456 |
|
21457 |
|
21458 |
|
21459 |
|
21460 | 'use strict';
|
21461 |
|
21462 | var punycode = require('punycode');
|
21463 | var util = require('./util');
|
21464 |
|
21465 | exports.parse = urlParse;
|
21466 | exports.resolve = urlResolve;
|
21467 | exports.resolveObject = urlResolveObject;
|
21468 | exports.format = urlFormat;
|
21469 |
|
21470 | exports.Url = Url;
|
21471 |
|
21472 | function 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 |
|
21488 |
|
21489 |
|
21490 |
|
21491 | var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
21492 | portPattern = /:[0-9]*$/,
|
21493 |
|
21494 |
|
21495 | simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
|
21496 |
|
21497 |
|
21498 |
|
21499 | delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
21500 |
|
21501 |
|
21502 | unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
|
21503 |
|
21504 |
|
21505 | autoEscape = ['\''].concat(unwise),
|
21506 |
|
21507 |
|
21508 |
|
21509 |
|
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 |
|
21516 | unsafeProtocol = {
|
21517 | 'javascript': true,
|
21518 | 'javascript:': true
|
21519 | },
|
21520 |
|
21521 | hostlessProtocol = {
|
21522 | 'javascript': true,
|
21523 | 'javascript:': true
|
21524 | },
|
21525 |
|
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 |
|
21540 | function 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 |
|
21548 | Url.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 |
|
21554 |
|
21555 |
|
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 |
|
21567 |
|
21568 | rest = rest.trim();
|
21569 |
|
21570 | if (!slashesDenoteHost && url.split('#').length === 1) {
|
21571 |
|
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 |
|
21601 |
|
21602 |
|
21603 |
|
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 |
|
21616 |
|
21617 |
|
21618 |
|
21619 |
|
21620 |
|
21621 |
|
21622 |
|
21623 |
|
21624 |
|
21625 |
|
21626 |
|
21627 |
|
21628 |
|
21629 |
|
21630 |
|
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 |
|
21639 |
|
21640 | var auth, atSign;
|
21641 | if (hostEnd === -1) {
|
21642 |
|
21643 | atSign = rest.lastIndexOf('@');
|
21644 | } else {
|
21645 |
|
21646 |
|
21647 | atSign = rest.lastIndexOf('@', hostEnd);
|
21648 | }
|
21649 |
|
21650 |
|
21651 |
|
21652 | if (atSign !== -1) {
|
21653 | auth = rest.slice(0, atSign);
|
21654 | rest = rest.slice(atSign + 1);
|
21655 | this.auth = decodeURIComponent(auth);
|
21656 | }
|
21657 |
|
21658 |
|
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 |
|
21666 | if (hostEnd === -1)
|
21667 | hostEnd = rest.length;
|
21668 |
|
21669 | this.host = rest.slice(0, hostEnd);
|
21670 | rest = rest.slice(hostEnd);
|
21671 |
|
21672 |
|
21673 | this.parseHost();
|
21674 |
|
21675 |
|
21676 |
|
21677 | this.hostname = this.hostname || '';
|
21678 |
|
21679 |
|
21680 |
|
21681 | var ipv6Hostname = this.hostname[0] === '[' &&
|
21682 | this.hostname[this.hostname.length - 1] === ']';
|
21683 |
|
21684 |
|
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 |
|
21695 |
|
21696 |
|
21697 | newpart += 'x';
|
21698 | } else {
|
21699 | newpart += part[j];
|
21700 | }
|
21701 | }
|
21702 |
|
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 |
|
21725 | this.hostname = this.hostname.toLowerCase();
|
21726 | }
|
21727 |
|
21728 | if (!ipv6Hostname) {
|
21729 |
|
21730 |
|
21731 |
|
21732 |
|
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 |
|
21742 |
|
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 |
|
21752 |
|
21753 | if (!unsafeProtocol[lowerProto]) {
|
21754 |
|
21755 |
|
21756 |
|
21757 |
|
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 |
|
21772 | var hash = rest.indexOf('#');
|
21773 | if (hash !== -1) {
|
21774 |
|
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 |
|
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 |
|
21798 | if (this.pathname || this.search) {
|
21799 | var p = this.pathname || '';
|
21800 | var s = this.search || '';
|
21801 | this.path = p + s;
|
21802 | }
|
21803 |
|
21804 |
|
21805 | this.href = this.format();
|
21806 | return this;
|
21807 | };
|
21808 |
|
21809 |
|
21810 | function urlFormat(obj) {
|
21811 |
|
21812 |
|
21813 |
|
21814 |
|
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 |
|
21820 | Url.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 |
|
21856 |
|
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 |
|
21876 | function urlResolve(source, relative) {
|
21877 | return urlParse(source, false, true).resolve(relative);
|
21878 | }
|
21879 |
|
21880 | Url.prototype.resolve = function(relative) {
|
21881 | return this.resolveObject(urlParse(relative, false, true)).format();
|
21882 | };
|
21883 |
|
21884 | function urlResolveObject(source, relative) {
|
21885 | if (!source) return relative;
|
21886 | return urlParse(source, false, true).resolveObject(relative);
|
21887 | }
|
21888 |
|
21889 | Url.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 |
|
21904 |
|
21905 | result.hash = relative.hash;
|
21906 |
|
21907 |
|
21908 | if (relative.href === '') {
|
21909 | result.href = result.format();
|
21910 | return result;
|
21911 | }
|
21912 |
|
21913 |
|
21914 | if (relative.slashes && !relative.protocol) {
|
21915 |
|
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 |
|
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 |
|
21935 |
|
21936 |
|
21937 |
|
21938 |
|
21939 |
|
21940 |
|
21941 |
|
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 |
|
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 |
|
21994 |
|
21995 |
|
21996 |
|
21997 |
|
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 |
|
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 |
|
22028 | } else if (relPath.length) {
|
22029 |
|
22030 |
|
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 |
|
22038 |
|
22039 |
|
22040 | if (psychotic) {
|
22041 | result.hostname = result.host = srcPath.shift();
|
22042 |
|
22043 |
|
22044 |
|
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 |
|
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 |
|
22065 |
|
22066 | result.pathname = null;
|
22067 |
|
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 |
|
22078 |
|
22079 |
|
22080 | var last = srcPath.slice(-1)[0];
|
22081 | var hasTrailingSlash = (
|
22082 | (result.host || relative.host || srcPath.length > 1) &&
|
22083 | (last === '.' || last === '..') || last === '');
|
22084 |
|
22085 |
|
22086 |
|
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 |
|
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 |
|
22121 | if (psychotic) {
|
22122 | result.hostname = result.host = isAbsolute ? '' :
|
22123 | srcPath.length ? srcPath.shift() : '';
|
22124 |
|
22125 |
|
22126 |
|
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 |
|
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 |
|
22159 | Url.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 |
|
22175 | module.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 |
|
22195 |
|
22196 |
|
22197 | module.exports = deprecate;
|
22198 |
|
22199 |
|
22200 |
|
22201 |
|
22202 |
|
22203 |
|
22204 |
|
22205 |
|
22206 |
|
22207 |
|
22208 |
|
22209 |
|
22210 |
|
22211 |
|
22212 |
|
22213 |
|
22214 |
|
22215 |
|
22216 |
|
22217 | function 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 |
|
22242 |
|
22243 |
|
22244 |
|
22245 |
|
22246 |
|
22247 |
|
22248 | function config (name) {
|
22249 |
|
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){
|
22263 | module.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 |
|
22272 |
|
22273 |
|
22274 |
|
22275 |
|
22276 |
|
22277 |
|
22278 |
|
22279 |
|
22280 |
|
22281 |
|
22282 |
|
22283 |
|
22284 |
|
22285 |
|
22286 |
|
22287 |
|
22288 |
|
22289 |
|
22290 |
|
22291 |
|
22292 | var formatRegExp = /%[sdj%]/g;
|
22293 | exports.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 |
|
22333 |
|
22334 |
|
22335 | exports.deprecate = function(fn, msg) {
|
22336 |
|
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 |
|
22366 | var debugs = {};
|
22367 | var debugEnviron;
|
22368 | exports.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 |
|
22395 | function inspect(obj, opts) {
|
22396 |
|
22397 | var ctx = {
|
22398 | seen: [],
|
22399 | stylize: stylizeNoColor
|
22400 | };
|
22401 |
|
22402 | if (arguments.length >= 3) ctx.depth = arguments[2];
|
22403 | if (arguments.length >= 4) ctx.colors = arguments[3];
|
22404 | if (isBoolean(opts)) {
|
22405 |
|
22406 | ctx.showHidden = opts;
|
22407 | } else if (opts) {
|
22408 |
|
22409 | exports._extend(ctx, opts);
|
22410 | }
|
22411 |
|
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 | }
|
22419 | exports.inspect = inspect;
|
22420 |
|
22421 |
|
22422 |
|
22423 | inspect.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 |
|
22440 | inspect.styles = {
|
22441 | 'special': 'cyan',
|
22442 | 'number': 'yellow',
|
22443 | 'boolean': 'yellow',
|
22444 | 'undefined': 'grey',
|
22445 | 'null': 'bold',
|
22446 | 'string': 'green',
|
22447 | 'date': 'magenta',
|
22448 |
|
22449 | 'regexp': 'red'
|
22450 | };
|
22451 |
|
22452 |
|
22453 | function 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 |
|
22465 | function stylizeNoColor(str, styleType) {
|
22466 | return str;
|
22467 | }
|
22468 |
|
22469 |
|
22470 | function arrayToHash(array) {
|
22471 | var hash = {};
|
22472 |
|
22473 | array.forEach(function(val, idx) {
|
22474 | hash[val] = true;
|
22475 | });
|
22476 |
|
22477 | return hash;
|
22478 | }
|
22479 |
|
22480 |
|
22481 | function formatValue(ctx, value, recurseTimes) {
|
22482 |
|
22483 |
|
22484 | if (ctx.customInspect &&
|
22485 | value &&
|
22486 | isFunction(value.inspect) &&
|
22487 |
|
22488 | value.inspect !== exports.inspect &&
|
22489 |
|
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 |
|
22499 | var primitive = formatPrimitive(ctx, value);
|
22500 | if (primitive) {
|
22501 | return primitive;
|
22502 | }
|
22503 |
|
22504 |
|
22505 | var keys = Object.keys(value);
|
22506 | var visibleKeys = arrayToHash(keys);
|
22507 |
|
22508 | if (ctx.showHidden) {
|
22509 | keys = Object.getOwnPropertyNames(value);
|
22510 | }
|
22511 |
|
22512 |
|
22513 |
|
22514 | if (isError(value)
|
22515 | && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
22516 | return formatError(value);
|
22517 | }
|
22518 |
|
22519 |
|
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 |
|
22539 | if (isArray(value)) {
|
22540 | array = true;
|
22541 | braces = ['[', ']'];
|
22542 | }
|
22543 |
|
22544 |
|
22545 | if (isFunction(value)) {
|
22546 | var n = value.name ? ': ' + value.name : '';
|
22547 | base = ' [Function' + n + ']';
|
22548 | }
|
22549 |
|
22550 |
|
22551 | if (isRegExp(value)) {
|
22552 | base = ' ' + RegExp.prototype.toString.call(value);
|
22553 | }
|
22554 |
|
22555 |
|
22556 | if (isDate(value)) {
|
22557 | base = ' ' + Date.prototype.toUTCString.call(value);
|
22558 | }
|
22559 |
|
22560 |
|
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 |
|
22594 | function 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 |
|
22608 | if (isNull(value))
|
22609 | return ctx.stylize('null', 'null');
|
22610 | }
|
22611 |
|
22612 |
|
22613 | function formatError(value) {
|
22614 | return '[' + Error.prototype.toString.call(value) + ']';
|
22615 | }
|
22616 |
|
22617 |
|
22618 | function 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 |
|
22638 | function 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 |
|
22697 | function 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 |
|
22719 |
|
22720 | function isArray(ar) {
|
22721 | return Array.isArray(ar);
|
22722 | }
|
22723 | exports.isArray = isArray;
|
22724 |
|
22725 | function isBoolean(arg) {
|
22726 | return typeof arg === 'boolean';
|
22727 | }
|
22728 | exports.isBoolean = isBoolean;
|
22729 |
|
22730 | function isNull(arg) {
|
22731 | return arg === null;
|
22732 | }
|
22733 | exports.isNull = isNull;
|
22734 |
|
22735 | function isNullOrUndefined(arg) {
|
22736 | return arg == null;
|
22737 | }
|
22738 | exports.isNullOrUndefined = isNullOrUndefined;
|
22739 |
|
22740 | function isNumber(arg) {
|
22741 | return typeof arg === 'number';
|
22742 | }
|
22743 | exports.isNumber = isNumber;
|
22744 |
|
22745 | function isString(arg) {
|
22746 | return typeof arg === 'string';
|
22747 | }
|
22748 | exports.isString = isString;
|
22749 |
|
22750 | function isSymbol(arg) {
|
22751 | return typeof arg === 'symbol';
|
22752 | }
|
22753 | exports.isSymbol = isSymbol;
|
22754 |
|
22755 | function isUndefined(arg) {
|
22756 | return arg === void 0;
|
22757 | }
|
22758 | exports.isUndefined = isUndefined;
|
22759 |
|
22760 | function isRegExp(re) {
|
22761 | return isObject(re) && objectToString(re) === '[object RegExp]';
|
22762 | }
|
22763 | exports.isRegExp = isRegExp;
|
22764 |
|
22765 | function isObject(arg) {
|
22766 | return typeof arg === 'object' && arg !== null;
|
22767 | }
|
22768 | exports.isObject = isObject;
|
22769 |
|
22770 | function isDate(d) {
|
22771 | return isObject(d) && objectToString(d) === '[object Date]';
|
22772 | }
|
22773 | exports.isDate = isDate;
|
22774 |
|
22775 | function isError(e) {
|
22776 | return isObject(e) &&
|
22777 | (objectToString(e) === '[object Error]' || e instanceof Error);
|
22778 | }
|
22779 | exports.isError = isError;
|
22780 |
|
22781 | function isFunction(arg) {
|
22782 | return typeof arg === 'function';
|
22783 | }
|
22784 | exports.isFunction = isFunction;
|
22785 |
|
22786 | function isPrimitive(arg) {
|
22787 | return arg === null ||
|
22788 | typeof arg === 'boolean' ||
|
22789 | typeof arg === 'number' ||
|
22790 | typeof arg === 'string' ||
|
22791 | typeof arg === 'symbol' ||
|
22792 | typeof arg === 'undefined';
|
22793 | }
|
22794 | exports.isPrimitive = isPrimitive;
|
22795 |
|
22796 | exports.isBuffer = require('./support/isBuffer');
|
22797 |
|
22798 | function objectToString(o) {
|
22799 | return Object.prototype.toString.call(o);
|
22800 | }
|
22801 |
|
22802 |
|
22803 | function pad(n) {
|
22804 | return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
22805 | }
|
22806 |
|
22807 |
|
22808 | var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
22809 | 'Oct', 'Nov', 'Dec'];
|
22810 |
|
22811 |
|
22812 | function 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 |
|
22822 | exports.log = function() {
|
22823 | console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
22824 | };
|
22825 |
|
22826 |
|
22827 |
|
22828 |
|
22829 |
|
22830 |
|
22831 |
|
22832 |
|
22833 |
|
22834 |
|
22835 |
|
22836 |
|
22837 |
|
22838 |
|
22839 |
|
22840 | exports.inherits = require('inherits');
|
22841 |
|
22842 | exports._extend = function(origin, add) {
|
22843 |
|
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 |
|
22854 | function 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 |
|
22863 | Object.defineProperty(exports, "__esModule", {
|
22864 | value: true
|
22865 | });
|
22866 | exports.default = void 0;
|
22867 |
|
22868 | var _toDate = _interopRequireDefault(require("./lib/toDate"));
|
22869 |
|
22870 | var _toFloat = _interopRequireDefault(require("./lib/toFloat"));
|
22871 |
|
22872 | var _toInt = _interopRequireDefault(require("./lib/toInt"));
|
22873 |
|
22874 | var _toBoolean = _interopRequireDefault(require("./lib/toBoolean"));
|
22875 |
|
22876 | var _equals = _interopRequireDefault(require("./lib/equals"));
|
22877 |
|
22878 | var _contains = _interopRequireDefault(require("./lib/contains"));
|
22879 |
|
22880 | var _matches = _interopRequireDefault(require("./lib/matches"));
|
22881 |
|
22882 | var _isEmail = _interopRequireDefault(require("./lib/isEmail"));
|
22883 |
|
22884 | var _isURL = _interopRequireDefault(require("./lib/isURL"));
|
22885 |
|
22886 | var _isMACAddress = _interopRequireDefault(require("./lib/isMACAddress"));
|
22887 |
|
22888 | var _isIP = _interopRequireDefault(require("./lib/isIP"));
|
22889 |
|
22890 | var _isIPRange = _interopRequireDefault(require("./lib/isIPRange"));
|
22891 |
|
22892 | var _isFQDN = _interopRequireDefault(require("./lib/isFQDN"));
|
22893 |
|
22894 | var _isBoolean = _interopRequireDefault(require("./lib/isBoolean"));
|
22895 |
|
22896 | var _isAlpha = _interopRequireWildcard(require("./lib/isAlpha"));
|
22897 |
|
22898 | var _isAlphanumeric = _interopRequireWildcard(require("./lib/isAlphanumeric"));
|
22899 |
|
22900 | var _isNumeric = _interopRequireDefault(require("./lib/isNumeric"));
|
22901 |
|
22902 | var _isPort = _interopRequireDefault(require("./lib/isPort"));
|
22903 |
|
22904 | var _isLowercase = _interopRequireDefault(require("./lib/isLowercase"));
|
22905 |
|
22906 | var _isUppercase = _interopRequireDefault(require("./lib/isUppercase"));
|
22907 |
|
22908 | var _isAscii = _interopRequireDefault(require("./lib/isAscii"));
|
22909 |
|
22910 | var _isFullWidth = _interopRequireDefault(require("./lib/isFullWidth"));
|
22911 |
|
22912 | var _isHalfWidth = _interopRequireDefault(require("./lib/isHalfWidth"));
|
22913 |
|
22914 | var _isVariableWidth = _interopRequireDefault(require("./lib/isVariableWidth"));
|
22915 |
|
22916 | var _isMultibyte = _interopRequireDefault(require("./lib/isMultibyte"));
|
22917 |
|
22918 | var _isSurrogatePair = _interopRequireDefault(require("./lib/isSurrogatePair"));
|
22919 |
|
22920 | var _isInt = _interopRequireDefault(require("./lib/isInt"));
|
22921 |
|
22922 | var _isFloat = _interopRequireWildcard(require("./lib/isFloat"));
|
22923 |
|
22924 | var _isDecimal = _interopRequireDefault(require("./lib/isDecimal"));
|
22925 |
|
22926 | var _isHexadecimal = _interopRequireDefault(require("./lib/isHexadecimal"));
|
22927 |
|
22928 | var _isDivisibleBy = _interopRequireDefault(require("./lib/isDivisibleBy"));
|
22929 |
|
22930 | var _isHexColor = _interopRequireDefault(require("./lib/isHexColor"));
|
22931 |
|
22932 | var _isISRC = _interopRequireDefault(require("./lib/isISRC"));
|
22933 |
|
22934 | var _isMD = _interopRequireDefault(require("./lib/isMD5"));
|
22935 |
|
22936 | var _isHash = _interopRequireDefault(require("./lib/isHash"));
|
22937 |
|
22938 | var _isJWT = _interopRequireDefault(require("./lib/isJWT"));
|
22939 |
|
22940 | var _isJSON = _interopRequireDefault(require("./lib/isJSON"));
|
22941 |
|
22942 | var _isEmpty = _interopRequireDefault(require("./lib/isEmpty"));
|
22943 |
|
22944 | var _isLength = _interopRequireDefault(require("./lib/isLength"));
|
22945 |
|
22946 | var _isByteLength = _interopRequireDefault(require("./lib/isByteLength"));
|
22947 |
|
22948 | var _isUUID = _interopRequireDefault(require("./lib/isUUID"));
|
22949 |
|
22950 | var _isMongoId = _interopRequireDefault(require("./lib/isMongoId"));
|
22951 |
|
22952 | var _isAfter = _interopRequireDefault(require("./lib/isAfter"));
|
22953 |
|
22954 | var _isBefore = _interopRequireDefault(require("./lib/isBefore"));
|
22955 |
|
22956 | var _isIn = _interopRequireDefault(require("./lib/isIn"));
|
22957 |
|
22958 | var _isCreditCard = _interopRequireDefault(require("./lib/isCreditCard"));
|
22959 |
|
22960 | var _isIdentityCard = _interopRequireDefault(require("./lib/isIdentityCard"));
|
22961 |
|
22962 | var _isISIN = _interopRequireDefault(require("./lib/isISIN"));
|
22963 |
|
22964 | var _isISBN = _interopRequireDefault(require("./lib/isISBN"));
|
22965 |
|
22966 | var _isISSN = _interopRequireDefault(require("./lib/isISSN"));
|
22967 |
|
22968 | var _isMobilePhone = _interopRequireWildcard(require("./lib/isMobilePhone"));
|
22969 |
|
22970 | var _isCurrency = _interopRequireDefault(require("./lib/isCurrency"));
|
22971 |
|
22972 | var _isISO = _interopRequireDefault(require("./lib/isISO8601"));
|
22973 |
|
22974 | var _isRFC = _interopRequireDefault(require("./lib/isRFC3339"));
|
22975 |
|
22976 | var _isISO31661Alpha = _interopRequireDefault(require("./lib/isISO31661Alpha2"));
|
22977 |
|
22978 | var _isISO31661Alpha2 = _interopRequireDefault(require("./lib/isISO31661Alpha3"));
|
22979 |
|
22980 | var _isBase = _interopRequireDefault(require("./lib/isBase64"));
|
22981 |
|
22982 | var _isDataURI = _interopRequireDefault(require("./lib/isDataURI"));
|
22983 |
|
22984 | var _isMagnetURI = _interopRequireDefault(require("./lib/isMagnetURI"));
|
22985 |
|
22986 | var _isMimeType = _interopRequireDefault(require("./lib/isMimeType"));
|
22987 |
|
22988 | var _isLatLong = _interopRequireDefault(require("./lib/isLatLong"));
|
22989 |
|
22990 | var _isPostalCode = _interopRequireWildcard(require("./lib/isPostalCode"));
|
22991 |
|
22992 | var _ltrim = _interopRequireDefault(require("./lib/ltrim"));
|
22993 |
|
22994 | var _rtrim = _interopRequireDefault(require("./lib/rtrim"));
|
22995 |
|
22996 | var _trim = _interopRequireDefault(require("./lib/trim"));
|
22997 |
|
22998 | var _escape = _interopRequireDefault(require("./lib/escape"));
|
22999 |
|
23000 | var _unescape = _interopRequireDefault(require("./lib/unescape"));
|
23001 |
|
23002 | var _stripLow = _interopRequireDefault(require("./lib/stripLow"));
|
23003 |
|
23004 | var _whitelist = _interopRequireDefault(require("./lib/whitelist"));
|
23005 |
|
23006 | var _blacklist = _interopRequireDefault(require("./lib/blacklist"));
|
23007 |
|
23008 | var _isWhitelisted = _interopRequireDefault(require("./lib/isWhitelisted"));
|
23009 |
|
23010 | var _normalizeEmail = _interopRequireDefault(require("./lib/normalizeEmail"));
|
23011 |
|
23012 | var _toString = _interopRequireDefault(require("./lib/util/toString"));
|
23013 |
|
23014 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { 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 |
|
23016 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23017 |
|
23018 | var version = '10.11.0';
|
23019 | var 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 | };
|
23100 | var _default = validator;
|
23101 | exports.default = _default;
|
23102 | module.exports = exports.default;
|
23103 | module.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 |
|
23107 | Object.defineProperty(exports, "__esModule", {
|
23108 | value: true
|
23109 | });
|
23110 | exports.commaDecimal = exports.dotDecimal = exports.arabicLocales = exports.englishLocales = exports.decimal = exports.alphanumeric = exports.alpha = void 0;
|
23111 | var 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 | };
|
23138 | exports.alpha = alpha;
|
23139 | var 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 | };
|
23166 | exports.alphanumeric = alphanumeric;
|
23167 | var decimal = {
|
23168 | 'en-US': '.',
|
23169 | ar: '٫'
|
23170 | };
|
23171 | exports.decimal = decimal;
|
23172 | var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
|
23173 | exports.englishLocales = englishLocales;
|
23174 |
|
23175 | for (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 | }
|
23181 |
|
23182 |
|
23183 | var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
|
23184 | exports.arabicLocales = arabicLocales;
|
23185 |
|
23186 | for (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 | }
|
23192 |
|
23193 |
|
23194 | var dotDecimal = [];
|
23195 | exports.dotDecimal = dotDecimal;
|
23196 | var 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'];
|
23197 | exports.commaDecimal = commaDecimal;
|
23198 |
|
23199 | for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
|
23200 | decimal[dotDecimal[_i2]] = decimal['en-US'];
|
23201 | }
|
23202 |
|
23203 | for (var _i3 = 0; _i3 < commaDecimal.length; _i3++) {
|
23204 | decimal[commaDecimal[_i3]] = ',';
|
23205 | }
|
23206 |
|
23207 | alpha['pt-BR'] = alpha['pt-PT'];
|
23208 | alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
|
23209 | decimal['pt-BR'] = decimal['pt-PT'];
|
23210 |
|
23211 | alpha['pl-Pl'] = alpha['pl-PL'];
|
23212 | alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
|
23213 | decimal['pl-Pl'] = decimal['pl-PL'];
|
23214 | },{}],155:[function(require,module,exports){
|
23215 | "use strict";
|
23216 |
|
23217 | Object.defineProperty(exports, "__esModule", {
|
23218 | value: true
|
23219 | });
|
23220 | exports.default = blacklist;
|
23221 |
|
23222 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23223 |
|
23224 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23225 |
|
23226 | function blacklist(str, chars) {
|
23227 | (0, _assertString.default)(str);
|
23228 | return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), '');
|
23229 | }
|
23230 |
|
23231 | module.exports = exports.default;
|
23232 | module.exports.default = exports.default;
|
23233 | },{"./util/assertString":226}],156:[function(require,module,exports){
|
23234 | "use strict";
|
23235 |
|
23236 | Object.defineProperty(exports, "__esModule", {
|
23237 | value: true
|
23238 | });
|
23239 | exports.default = contains;
|
23240 |
|
23241 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23242 |
|
23243 | var _toString = _interopRequireDefault(require("./util/toString"));
|
23244 |
|
23245 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23246 |
|
23247 | function contains(str, elem) {
|
23248 | (0, _assertString.default)(str);
|
23249 | return str.indexOf((0, _toString.default)(elem)) >= 0;
|
23250 | }
|
23251 |
|
23252 | module.exports = exports.default;
|
23253 | module.exports.default = exports.default;
|
23254 | },{"./util/assertString":226,"./util/toString":229}],157:[function(require,module,exports){
|
23255 | "use strict";
|
23256 |
|
23257 | Object.defineProperty(exports, "__esModule", {
|
23258 | value: true
|
23259 | });
|
23260 | exports.default = equals;
|
23261 |
|
23262 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23263 |
|
23264 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23265 |
|
23266 | function equals(str, comparison) {
|
23267 | (0, _assertString.default)(str);
|
23268 | return str === comparison;
|
23269 | }
|
23270 |
|
23271 | module.exports = exports.default;
|
23272 | module.exports.default = exports.default;
|
23273 | },{"./util/assertString":226}],158:[function(require,module,exports){
|
23274 | "use strict";
|
23275 |
|
23276 | Object.defineProperty(exports, "__esModule", {
|
23277 | value: true
|
23278 | });
|
23279 | exports.default = escape;
|
23280 |
|
23281 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23282 |
|
23283 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23284 |
|
23285 | function escape(str) {
|
23286 | (0, _assertString.default)(str);
|
23287 | return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/\//g, '/').replace(/\\/g, '\').replace(/`/g, '`');
|
23288 | }
|
23289 |
|
23290 | module.exports = exports.default;
|
23291 | module.exports.default = exports.default;
|
23292 | },{"./util/assertString":226}],159:[function(require,module,exports){
|
23293 | "use strict";
|
23294 |
|
23295 | Object.defineProperty(exports, "__esModule", {
|
23296 | value: true
|
23297 | });
|
23298 | exports.default = isAfter;
|
23299 |
|
23300 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23301 |
|
23302 | var _toDate = _interopRequireDefault(require("./toDate"));
|
23303 |
|
23304 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23305 |
|
23306 | function 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 |
|
23314 | module.exports = exports.default;
|
23315 | module.exports.default = exports.default;
|
23316 | },{"./toDate":221,"./util/assertString":226}],160:[function(require,module,exports){
|
23317 | "use strict";
|
23318 |
|
23319 | Object.defineProperty(exports, "__esModule", {
|
23320 | value: true
|
23321 | });
|
23322 | exports.default = isAlpha;
|
23323 | exports.locales = void 0;
|
23324 |
|
23325 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23326 |
|
23327 | var _alpha = require("./alpha");
|
23328 |
|
23329 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23330 |
|
23331 | function 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 |
|
23342 | var locales = Object.keys(_alpha.alpha);
|
23343 | exports.locales = locales;
|
23344 | },{"./alpha":154,"./util/assertString":226}],161:[function(require,module,exports){
|
23345 | "use strict";
|
23346 |
|
23347 | Object.defineProperty(exports, "__esModule", {
|
23348 | value: true
|
23349 | });
|
23350 | exports.default = isAlphanumeric;
|
23351 | exports.locales = void 0;
|
23352 |
|
23353 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23354 |
|
23355 | var _alpha = require("./alpha");
|
23356 |
|
23357 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23358 |
|
23359 | function 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 |
|
23370 | var locales = Object.keys(_alpha.alphanumeric);
|
23371 | exports.locales = locales;
|
23372 | },{"./alpha":154,"./util/assertString":226}],162:[function(require,module,exports){
|
23373 | "use strict";
|
23374 |
|
23375 | Object.defineProperty(exports, "__esModule", {
|
23376 | value: true
|
23377 | });
|
23378 | exports.default = isAscii;
|
23379 |
|
23380 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23381 |
|
23382 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23383 |
|
23384 |
|
23385 | var ascii = /^[\x00-\x7F]+$/;
|
23386 |
|
23387 |
|
23388 | function isAscii(str) {
|
23389 | (0, _assertString.default)(str);
|
23390 | return ascii.test(str);
|
23391 | }
|
23392 |
|
23393 | module.exports = exports.default;
|
23394 | module.exports.default = exports.default;
|
23395 | },{"./util/assertString":226}],163:[function(require,module,exports){
|
23396 | "use strict";
|
23397 |
|
23398 | Object.defineProperty(exports, "__esModule", {
|
23399 | value: true
|
23400 | });
|
23401 | exports.default = isBase64;
|
23402 |
|
23403 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23404 |
|
23405 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23406 |
|
23407 | var notBase64 = /[^A-Z0-9+\/=]/i;
|
23408 |
|
23409 | function 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 |
|
23421 | module.exports = exports.default;
|
23422 | module.exports.default = exports.default;
|
23423 | },{"./util/assertString":226}],164:[function(require,module,exports){
|
23424 | "use strict";
|
23425 |
|
23426 | Object.defineProperty(exports, "__esModule", {
|
23427 | value: true
|
23428 | });
|
23429 | exports.default = isBefore;
|
23430 |
|
23431 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23432 |
|
23433 | var _toDate = _interopRequireDefault(require("./toDate"));
|
23434 |
|
23435 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23436 |
|
23437 | function 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 |
|
23445 | module.exports = exports.default;
|
23446 | module.exports.default = exports.default;
|
23447 | },{"./toDate":221,"./util/assertString":226}],165:[function(require,module,exports){
|
23448 | "use strict";
|
23449 |
|
23450 | Object.defineProperty(exports, "__esModule", {
|
23451 | value: true
|
23452 | });
|
23453 | exports.default = isBoolean;
|
23454 |
|
23455 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23456 |
|
23457 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23458 |
|
23459 | function isBoolean(str) {
|
23460 | (0, _assertString.default)(str);
|
23461 | return ['true', 'false', '1', '0'].indexOf(str) >= 0;
|
23462 | }
|
23463 |
|
23464 | module.exports = exports.default;
|
23465 | module.exports.default = exports.default;
|
23466 | },{"./util/assertString":226}],166:[function(require,module,exports){
|
23467 | "use strict";
|
23468 |
|
23469 | Object.defineProperty(exports, "__esModule", {
|
23470 | value: true
|
23471 | });
|
23472 | exports.default = isByteLength;
|
23473 |
|
23474 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23475 |
|
23476 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23477 |
|
23478 | function _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 |
|
23481 | function 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 |
|
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 |
|
23499 | module.exports = exports.default;
|
23500 | module.exports.default = exports.default;
|
23501 | },{"./util/assertString":226}],167:[function(require,module,exports){
|
23502 | "use strict";
|
23503 |
|
23504 | Object.defineProperty(exports, "__esModule", {
|
23505 | value: true
|
23506 | });
|
23507 | exports.default = isCreditCard;
|
23508 |
|
23509 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23510 |
|
23511 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23512 |
|
23513 |
|
23514 | var 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 |
|
23516 |
|
23517 | function 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 |
|
23552 | module.exports = exports.default;
|
23553 | module.exports.default = exports.default;
|
23554 | },{"./util/assertString":226}],168:[function(require,module,exports){
|
23555 | "use strict";
|
23556 |
|
23557 | Object.defineProperty(exports, "__esModule", {
|
23558 | value: true
|
23559 | });
|
23560 | exports.default = isCurrency;
|
23561 |
|
23562 | var _merge = _interopRequireDefault(require("./util/merge"));
|
23563 |
|
23564 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23565 |
|
23566 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23567 |
|
23568 | function 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 : '');
|
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 | }
|
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 | }
|
23612 |
|
23613 |
|
23614 |
|
23615 | return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
|
23616 | }
|
23617 |
|
23618 | var 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 |
|
23636 | function 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 |
|
23642 | module.exports = exports.default;
|
23643 | module.exports.default = exports.default;
|
23644 | },{"./util/assertString":226,"./util/merge":228}],169:[function(require,module,exports){
|
23645 | "use strict";
|
23646 |
|
23647 | Object.defineProperty(exports, "__esModule", {
|
23648 | value: true
|
23649 | });
|
23650 | exports.default = isDataURI;
|
23651 |
|
23652 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23653 |
|
23654 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23655 |
|
23656 | var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
|
23657 | var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
|
23658 | var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
|
23659 |
|
23660 | function 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') {
|
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 |
|
23697 | module.exports = exports.default;
|
23698 | module.exports.default = exports.default;
|
23699 | },{"./util/assertString":226}],170:[function(require,module,exports){
|
23700 | "use strict";
|
23701 |
|
23702 | Object.defineProperty(exports, "__esModule", {
|
23703 | value: true
|
23704 | });
|
23705 | exports.default = isDecimal;
|
23706 |
|
23707 | var _merge = _interopRequireDefault(require("./util/merge"));
|
23708 |
|
23709 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23710 |
|
23711 | var _includes = _interopRequireDefault(require("./util/includes"));
|
23712 |
|
23713 | var _alpha = require("./alpha");
|
23714 |
|
23715 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23716 |
|
23717 | function 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 |
|
23722 | var default_decimal_options = {
|
23723 | force_decimal: false,
|
23724 | decimal_digits: '1,',
|
23725 | locale: 'en-US'
|
23726 | };
|
23727 | var blacklist = ['', '-', '+'];
|
23728 |
|
23729 | function 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 |
|
23740 | module.exports = exports.default;
|
23741 | module.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 |
|
23745 | Object.defineProperty(exports, "__esModule", {
|
23746 | value: true
|
23747 | });
|
23748 | exports.default = isDivisibleBy;
|
23749 |
|
23750 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23751 |
|
23752 | var _toFloat = _interopRequireDefault(require("./toFloat"));
|
23753 |
|
23754 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23755 |
|
23756 | function isDivisibleBy(str, num) {
|
23757 | (0, _assertString.default)(str);
|
23758 | return (0, _toFloat.default)(str) % parseInt(num, 10) === 0;
|
23759 | }
|
23760 |
|
23761 | module.exports = exports.default;
|
23762 | module.exports.default = exports.default;
|
23763 | },{"./toFloat":222,"./util/assertString":226}],172:[function(require,module,exports){
|
23764 | "use strict";
|
23765 |
|
23766 | Object.defineProperty(exports, "__esModule", {
|
23767 | value: true
|
23768 | });
|
23769 | exports.default = isEmail;
|
23770 |
|
23771 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23772 |
|
23773 | var _merge = _interopRequireDefault(require("./util/merge"));
|
23774 |
|
23775 | var _isByteLength = _interopRequireDefault(require("./isByteLength"));
|
23776 |
|
23777 | var _isFQDN = _interopRequireDefault(require("./isFQDN"));
|
23778 |
|
23779 | var _isIP = _interopRequireDefault(require("./isIP"));
|
23780 |
|
23781 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23782 |
|
23783 | var 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 |
|
23790 |
|
23791 |
|
23792 |
|
23793 | var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i;
|
23794 | var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
|
23795 | var gmailUserPart = /^[a-z\d]+$/;
|
23796 | var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
|
23797 | var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
|
23798 | var 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 |
|
23800 |
|
23801 |
|
23802 |
|
23803 | function 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 |
|
23825 |
|
23826 |
|
23827 |
|
23828 |
|
23829 |
|
23830 | user = user.toLowerCase();
|
23831 |
|
23832 | var username = user.split('+')[0];
|
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 |
|
23895 | module.exports = exports.default;
|
23896 | module.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 |
|
23900 | Object.defineProperty(exports, "__esModule", {
|
23901 | value: true
|
23902 | });
|
23903 | exports.default = isEmpty;
|
23904 |
|
23905 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23906 |
|
23907 | var _merge = _interopRequireDefault(require("./util/merge"));
|
23908 |
|
23909 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23910 |
|
23911 | var default_is_empty_options = {
|
23912 | ignore_whitespace: false
|
23913 | };
|
23914 |
|
23915 | function 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 |
|
23921 | module.exports = exports.default;
|
23922 | module.exports.default = exports.default;
|
23923 | },{"./util/assertString":226,"./util/merge":228}],174:[function(require,module,exports){
|
23924 | "use strict";
|
23925 |
|
23926 | Object.defineProperty(exports, "__esModule", {
|
23927 | value: true
|
23928 | });
|
23929 | exports.default = isFQDN;
|
23930 |
|
23931 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
23932 |
|
23933 | var _merge = _interopRequireDefault(require("./util/merge"));
|
23934 |
|
23935 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23936 |
|
23937 | var default_fqdn_options = {
|
23938 | require_tld: true,
|
23939 | allow_underscores: false,
|
23940 | allow_trailing_dot: false
|
23941 | };
|
23942 |
|
23943 | function isFQDN(str, options) {
|
23944 | (0, _assertString.default)(str);
|
23945 | options = (0, _merge.default)(options, default_fqdn_options);
|
23946 |
|
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 | }
|
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 | }
|
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 |
|
23997 | module.exports = exports.default;
|
23998 | module.exports.default = exports.default;
|
23999 | },{"./util/assertString":226,"./util/merge":228}],175:[function(require,module,exports){
|
24000 | "use strict";
|
24001 |
|
24002 | Object.defineProperty(exports, "__esModule", {
|
24003 | value: true
|
24004 | });
|
24005 | exports.default = isFloat;
|
24006 | exports.locales = void 0;
|
24007 |
|
24008 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24009 |
|
24010 | var _alpha = require("./alpha");
|
24011 |
|
24012 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24013 |
|
24014 | function 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 |
|
24027 | var locales = Object.keys(_alpha.decimal);
|
24028 | exports.locales = locales;
|
24029 | },{"./alpha":154,"./util/assertString":226}],176:[function(require,module,exports){
|
24030 | "use strict";
|
24031 |
|
24032 | Object.defineProperty(exports, "__esModule", {
|
24033 | value: true
|
24034 | });
|
24035 | exports.default = isFullWidth;
|
24036 | exports.fullWidth = void 0;
|
24037 |
|
24038 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24039 |
|
24040 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24041 |
|
24042 | var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
|
24043 | exports.fullWidth = fullWidth;
|
24044 |
|
24045 | function 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 |
|
24052 | Object.defineProperty(exports, "__esModule", {
|
24053 | value: true
|
24054 | });
|
24055 | exports.default = isHalfWidth;
|
24056 | exports.halfWidth = void 0;
|
24057 |
|
24058 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24059 |
|
24060 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24061 |
|
24062 | var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
|
24063 | exports.halfWidth = halfWidth;
|
24064 |
|
24065 | function 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 |
|
24072 | Object.defineProperty(exports, "__esModule", {
|
24073 | value: true
|
24074 | });
|
24075 | exports.default = isHash;
|
24076 |
|
24077 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24078 |
|
24079 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24080 |
|
24081 | var 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 |
|
24097 | function 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 |
|
24103 | module.exports = exports.default;
|
24104 | module.exports.default = exports.default;
|
24105 | },{"./util/assertString":226}],179:[function(require,module,exports){
|
24106 | "use strict";
|
24107 |
|
24108 | Object.defineProperty(exports, "__esModule", {
|
24109 | value: true
|
24110 | });
|
24111 | exports.default = isHexColor;
|
24112 |
|
24113 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24114 |
|
24115 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24116 |
|
24117 | var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;
|
24118 |
|
24119 | function isHexColor(str) {
|
24120 | (0, _assertString.default)(str);
|
24121 | return hexcolor.test(str);
|
24122 | }
|
24123 |
|
24124 | module.exports = exports.default;
|
24125 | module.exports.default = exports.default;
|
24126 | },{"./util/assertString":226}],180:[function(require,module,exports){
|
24127 | "use strict";
|
24128 |
|
24129 | Object.defineProperty(exports, "__esModule", {
|
24130 | value: true
|
24131 | });
|
24132 | exports.default = isHexadecimal;
|
24133 |
|
24134 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24135 |
|
24136 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24137 |
|
24138 | var hexadecimal = /^[0-9A-F]+$/i;
|
24139 |
|
24140 | function isHexadecimal(str) {
|
24141 | (0, _assertString.default)(str);
|
24142 | return hexadecimal.test(str);
|
24143 | }
|
24144 |
|
24145 | module.exports = exports.default;
|
24146 | module.exports.default = exports.default;
|
24147 | },{"./util/assertString":226}],181:[function(require,module,exports){
|
24148 | "use strict";
|
24149 |
|
24150 | Object.defineProperty(exports, "__esModule", {
|
24151 | value: true
|
24152 | });
|
24153 | exports.default = isIP;
|
24154 |
|
24155 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24156 |
|
24157 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24158 |
|
24159 | var ipv4Maybe = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
24160 | var ipv6Block = /^[0-9A-F]{1,4}$/i;
|
24161 |
|
24162 | function 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;
|
24181 |
|
24182 |
|
24183 |
|
24184 |
|
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 | }
|
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 |
|
24208 |
|
24209 | if (blocks[i] === '' && i > 0 && i < blocks.length - 1) {
|
24210 | if (foundOmissionBlock) {
|
24211 | return false;
|
24212 | }
|
24213 |
|
24214 | foundOmissionBlock = true;
|
24215 | } else if (foundIPv4TransitionBlock && i === blocks.length - 1) {
|
24216 |
|
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 |
|
24232 | module.exports = exports.default;
|
24233 | module.exports.default = exports.default;
|
24234 | },{"./util/assertString":226}],182:[function(require,module,exports){
|
24235 | "use strict";
|
24236 |
|
24237 | Object.defineProperty(exports, "__esModule", {
|
24238 | value: true
|
24239 | });
|
24240 | exports.default = isIPRange;
|
24241 |
|
24242 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24243 |
|
24244 | var _isIP = _interopRequireDefault(require("./isIP"));
|
24245 |
|
24246 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24247 |
|
24248 | var subnetMaybe = /^\d{1,2}$/;
|
24249 |
|
24250 | function isIPRange(str) {
|
24251 | (0, _assertString.default)(str);
|
24252 | var parts = str.split('/');
|
24253 |
|
24254 | if (parts.length !== 2) {
|
24255 | return false;
|
24256 | }
|
24257 |
|
24258 | if (!subnetMaybe.test(parts[1])) {
|
24259 | return false;
|
24260 | }
|
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 |
|
24270 | module.exports = exports.default;
|
24271 | module.exports.default = exports.default;
|
24272 | },{"./isIP":181,"./util/assertString":226}],183:[function(require,module,exports){
|
24273 | "use strict";
|
24274 |
|
24275 | Object.defineProperty(exports, "__esModule", {
|
24276 | value: true
|
24277 | });
|
24278 | exports.default = isISBN;
|
24279 |
|
24280 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24281 |
|
24282 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24283 |
|
24284 | var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
|
24285 | var isbn13Maybe = /^(?:[0-9]{13})$/;
|
24286 | var factor = [1, 3];
|
24287 |
|
24288 | function 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 |
|
24336 | module.exports = exports.default;
|
24337 | module.exports.default = exports.default;
|
24338 | },{"./util/assertString":226}],184:[function(require,module,exports){
|
24339 | "use strict";
|
24340 |
|
24341 | Object.defineProperty(exports, "__esModule", {
|
24342 | value: true
|
24343 | });
|
24344 | exports.default = isISIN;
|
24345 |
|
24346 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24347 |
|
24348 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24349 |
|
24350 | var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
|
24351 |
|
24352 | function 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 |
|
24389 | module.exports = exports.default;
|
24390 | module.exports.default = exports.default;
|
24391 | },{"./util/assertString":226}],185:[function(require,module,exports){
|
24392 | "use strict";
|
24393 |
|
24394 | Object.defineProperty(exports, "__esModule", {
|
24395 | value: true
|
24396 | });
|
24397 | exports.default = isISO31661Alpha2;
|
24398 |
|
24399 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24400 |
|
24401 | var _includes = _interopRequireDefault(require("./util/includes"));
|
24402 |
|
24403 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24404 |
|
24405 |
|
24406 | var 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 |
|
24408 | function isISO31661Alpha2(str) {
|
24409 | (0, _assertString.default)(str);
|
24410 | return (0, _includes.default)(validISO31661Alpha2CountriesCodes, str.toUpperCase());
|
24411 | }
|
24412 |
|
24413 | module.exports = exports.default;
|
24414 | module.exports.default = exports.default;
|
24415 | },{"./util/assertString":226,"./util/includes":227}],186:[function(require,module,exports){
|
24416 | "use strict";
|
24417 |
|
24418 | Object.defineProperty(exports, "__esModule", {
|
24419 | value: true
|
24420 | });
|
24421 | exports.default = isISO31661Alpha3;
|
24422 |
|
24423 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24424 |
|
24425 | var _includes = _interopRequireDefault(require("./util/includes"));
|
24426 |
|
24427 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24428 |
|
24429 |
|
24430 | var 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 |
|
24432 | function isISO31661Alpha3(str) {
|
24433 | (0, _assertString.default)(str);
|
24434 | return (0, _includes.default)(validISO31661Alpha3CountriesCodes, str.toUpperCase());
|
24435 | }
|
24436 |
|
24437 | module.exports = exports.default;
|
24438 | module.exports.default = exports.default;
|
24439 | },{"./util/assertString":226,"./util/includes":227}],187:[function(require,module,exports){
|
24440 | "use strict";
|
24441 |
|
24442 | Object.defineProperty(exports, "__esModule", {
|
24443 | value: true
|
24444 | });
|
24445 | exports.default = isISO8601;
|
24446 |
|
24447 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24448 |
|
24449 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24450 |
|
24451 |
|
24452 |
|
24453 | var 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 |
|
24455 |
|
24456 | var isValidDate = function isValidDate(str) {
|
24457 |
|
24458 |
|
24459 |
|
24460 |
|
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]);
|
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;
|
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 |
|
24488 | function 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 |
|
24496 | module.exports = exports.default;
|
24497 | module.exports.default = exports.default;
|
24498 | },{"./util/assertString":226}],188:[function(require,module,exports){
|
24499 | "use strict";
|
24500 |
|
24501 | Object.defineProperty(exports, "__esModule", {
|
24502 | value: true
|
24503 | });
|
24504 | exports.default = isISRC;
|
24505 |
|
24506 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24507 |
|
24508 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24509 |
|
24510 |
|
24511 | var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
|
24512 |
|
24513 | function isISRC(str) {
|
24514 | (0, _assertString.default)(str);
|
24515 | return isrc.test(str);
|
24516 | }
|
24517 |
|
24518 | module.exports = exports.default;
|
24519 | module.exports.default = exports.default;
|
24520 | },{"./util/assertString":226}],189:[function(require,module,exports){
|
24521 | "use strict";
|
24522 |
|
24523 | Object.defineProperty(exports, "__esModule", {
|
24524 | value: true
|
24525 | });
|
24526 | exports.default = isISSN;
|
24527 |
|
24528 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24529 |
|
24530 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24531 |
|
24532 | var issn = '^\\d{4}-?\\d{3}[\\dX]$';
|
24533 |
|
24534 | function 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 |
|
24556 | module.exports = exports.default;
|
24557 | module.exports.default = exports.default;
|
24558 | },{"./util/assertString":226}],190:[function(require,module,exports){
|
24559 | "use strict";
|
24560 |
|
24561 | Object.defineProperty(exports, "__esModule", {
|
24562 | value: true
|
24563 | });
|
24564 | exports.default = isIdentityCard;
|
24565 |
|
24566 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24567 |
|
24568 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24569 |
|
24570 | var 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'];
|
24580 |
|
24581 | var sanitized = str.trim().toUpperCase();
|
24582 |
|
24583 | if (!DNI.test(sanitized)) {
|
24584 | return false;
|
24585 | }
|
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 |
|
24595 | function 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 |
|
24618 | module.exports = exports.default;
|
24619 | module.exports.default = exports.default;
|
24620 | },{"./util/assertString":226}],191:[function(require,module,exports){
|
24621 | "use strict";
|
24622 |
|
24623 | Object.defineProperty(exports, "__esModule", {
|
24624 | value: true
|
24625 | });
|
24626 | exports.default = isIn;
|
24627 |
|
24628 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24629 |
|
24630 | var _toString = _interopRequireDefault(require("./util/toString"));
|
24631 |
|
24632 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24633 |
|
24634 | function _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 |
|
24636 | function 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 |
|
24659 | module.exports = exports.default;
|
24660 | module.exports.default = exports.default;
|
24661 | },{"./util/assertString":226,"./util/toString":229}],192:[function(require,module,exports){
|
24662 | "use strict";
|
24663 |
|
24664 | Object.defineProperty(exports, "__esModule", {
|
24665 | value: true
|
24666 | });
|
24667 | exports.default = isInt;
|
24668 |
|
24669 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24670 |
|
24671 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24672 |
|
24673 | var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
|
24674 | var intLeadingZeroes = /^[-+]?[0-9]+$/;
|
24675 |
|
24676 | function isInt(str, options) {
|
24677 | (0, _assertString.default)(str);
|
24678 | options = options || {};
|
24679 |
|
24680 |
|
24681 | var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? int : intLeadingZeroes;
|
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 |
|
24690 | module.exports = exports.default;
|
24691 | module.exports.default = exports.default;
|
24692 | },{"./util/assertString":226}],193:[function(require,module,exports){
|
24693 | "use strict";
|
24694 |
|
24695 | Object.defineProperty(exports, "__esModule", {
|
24696 | value: true
|
24697 | });
|
24698 | exports.default = isJSON;
|
24699 |
|
24700 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24701 |
|
24702 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24703 |
|
24704 | function _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 |
|
24706 | function 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 |
|
24714 | }
|
24715 |
|
24716 | return false;
|
24717 | }
|
24718 |
|
24719 | module.exports = exports.default;
|
24720 | module.exports.default = exports.default;
|
24721 | },{"./util/assertString":226}],194:[function(require,module,exports){
|
24722 | "use strict";
|
24723 |
|
24724 | Object.defineProperty(exports, "__esModule", {
|
24725 | value: true
|
24726 | });
|
24727 | exports.default = isJWT;
|
24728 |
|
24729 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24730 |
|
24731 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24732 |
|
24733 | var jwt = /^([A-Za-z0-9\-_~+\/]+[=]{0,2})\.([A-Za-z0-9\-_~+\/]+[=]{0,2})(?:\.([A-Za-z0-9\-_~+\/]+[=]{0,2}))?$/;
|
24734 |
|
24735 | function isJWT(str) {
|
24736 | (0, _assertString.default)(str);
|
24737 | return jwt.test(str);
|
24738 | }
|
24739 |
|
24740 | module.exports = exports.default;
|
24741 | module.exports.default = exports.default;
|
24742 | },{"./util/assertString":226}],195:[function(require,module,exports){
|
24743 | "use strict";
|
24744 |
|
24745 | Object.defineProperty(exports, "__esModule", {
|
24746 | value: true
|
24747 | });
|
24748 | exports.default = _default;
|
24749 |
|
24750 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24751 |
|
24752 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24753 |
|
24754 | var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
|
24755 | var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
|
24756 |
|
24757 | function _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 |
|
24764 | module.exports = exports.default;
|
24765 | module.exports.default = exports.default;
|
24766 | },{"./util/assertString":226}],196:[function(require,module,exports){
|
24767 | "use strict";
|
24768 |
|
24769 | Object.defineProperty(exports, "__esModule", {
|
24770 | value: true
|
24771 | });
|
24772 | exports.default = isLength;
|
24773 |
|
24774 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24775 |
|
24776 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24777 |
|
24778 | function _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 |
|
24781 | function 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 |
|
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 |
|
24800 | module.exports = exports.default;
|
24801 | module.exports.default = exports.default;
|
24802 | },{"./util/assertString":226}],197:[function(require,module,exports){
|
24803 | "use strict";
|
24804 |
|
24805 | Object.defineProperty(exports, "__esModule", {
|
24806 | value: true
|
24807 | });
|
24808 | exports.default = isLowercase;
|
24809 |
|
24810 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24811 |
|
24812 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24813 |
|
24814 | function isLowercase(str) {
|
24815 | (0, _assertString.default)(str);
|
24816 | return str === str.toLowerCase();
|
24817 | }
|
24818 |
|
24819 | module.exports = exports.default;
|
24820 | module.exports.default = exports.default;
|
24821 | },{"./util/assertString":226}],198:[function(require,module,exports){
|
24822 | "use strict";
|
24823 |
|
24824 | Object.defineProperty(exports, "__esModule", {
|
24825 | value: true
|
24826 | });
|
24827 | exports.default = isMACAddress;
|
24828 |
|
24829 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24830 |
|
24831 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24832 |
|
24833 | var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
|
24834 | var macAddressNoColons = /^([0-9a-fA-F]){12}$/;
|
24835 |
|
24836 | function 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 |
|
24846 | module.exports = exports.default;
|
24847 | module.exports.default = exports.default;
|
24848 | },{"./util/assertString":226}],199:[function(require,module,exports){
|
24849 | "use strict";
|
24850 |
|
24851 | Object.defineProperty(exports, "__esModule", {
|
24852 | value: true
|
24853 | });
|
24854 | exports.default = isMD5;
|
24855 |
|
24856 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24857 |
|
24858 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24859 |
|
24860 | var md5 = /^[a-f0-9]{32}$/;
|
24861 |
|
24862 | function isMD5(str) {
|
24863 | (0, _assertString.default)(str);
|
24864 | return md5.test(str);
|
24865 | }
|
24866 |
|
24867 | module.exports = exports.default;
|
24868 | module.exports.default = exports.default;
|
24869 | },{"./util/assertString":226}],200:[function(require,module,exports){
|
24870 | "use strict";
|
24871 |
|
24872 | Object.defineProperty(exports, "__esModule", {
|
24873 | value: true
|
24874 | });
|
24875 | exports.default = isMagnetURI;
|
24876 |
|
24877 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24878 |
|
24879 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24880 |
|
24881 | var magnetURI = /^magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}&dn=.+&tr=.+$/i;
|
24882 |
|
24883 | function isMagnetURI(url) {
|
24884 | (0, _assertString.default)(url);
|
24885 | return magnetURI.test(url.trim());
|
24886 | }
|
24887 |
|
24888 | module.exports = exports.default;
|
24889 | module.exports.default = exports.default;
|
24890 | },{"./util/assertString":226}],201:[function(require,module,exports){
|
24891 | "use strict";
|
24892 |
|
24893 | Object.defineProperty(exports, "__esModule", {
|
24894 | value: true
|
24895 | });
|
24896 | exports.default = isMimeType;
|
24897 |
|
24898 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24899 |
|
24900 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24901 |
|
24902 |
|
24903 |
|
24904 |
|
24905 |
|
24906 |
|
24907 |
|
24908 |
|
24909 |
|
24910 |
|
24911 |
|
24912 |
|
24913 |
|
24914 |
|
24915 |
|
24916 |
|
24917 |
|
24918 |
|
24919 |
|
24920 |
|
24921 |
|
24922 |
|
24923 |
|
24924 |
|
24925 |
|
24926 |
|
24927 | var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i;
|
24928 |
|
24929 |
|
24930 | var 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;
|
24931 |
|
24932 |
|
24933 | var 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;
|
24934 |
|
24935 | function isMimeType(str) {
|
24936 | (0, _assertString.default)(str);
|
24937 | return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
|
24938 | }
|
24939 |
|
24940 | module.exports = exports.default;
|
24941 | module.exports.default = exports.default;
|
24942 | },{"./util/assertString":226}],202:[function(require,module,exports){
|
24943 | "use strict";
|
24944 |
|
24945 | Object.defineProperty(exports, "__esModule", {
|
24946 | value: true
|
24947 | });
|
24948 | exports.default = isMobilePhone;
|
24949 | exports.locales = void 0;
|
24950 |
|
24951 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
24952 |
|
24953 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24954 |
|
24955 |
|
24956 | var 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 |
|
25029 |
|
25030 |
|
25031 | phones['en-CA'] = phones['en-US'];
|
25032 | phones['fr-BE'] = phones['nl-BE'];
|
25033 | phones['zh-HK'] = phones['en-HK'];
|
25034 |
|
25035 | function 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);
|
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 |
|
25073 | var locales = Object.keys(phones);
|
25074 | exports.locales = locales;
|
25075 | },{"./util/assertString":226}],203:[function(require,module,exports){
|
25076 | "use strict";
|
25077 |
|
25078 | Object.defineProperty(exports, "__esModule", {
|
25079 | value: true
|
25080 | });
|
25081 | exports.default = isMongoId;
|
25082 |
|
25083 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25084 |
|
25085 | var _isHexadecimal = _interopRequireDefault(require("./isHexadecimal"));
|
25086 |
|
25087 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25088 |
|
25089 | function isMongoId(str) {
|
25090 | (0, _assertString.default)(str);
|
25091 | return (0, _isHexadecimal.default)(str) && str.length === 24;
|
25092 | }
|
25093 |
|
25094 | module.exports = exports.default;
|
25095 | module.exports.default = exports.default;
|
25096 | },{"./isHexadecimal":180,"./util/assertString":226}],204:[function(require,module,exports){
|
25097 | "use strict";
|
25098 |
|
25099 | Object.defineProperty(exports, "__esModule", {
|
25100 | value: true
|
25101 | });
|
25102 | exports.default = isMultibyte;
|
25103 |
|
25104 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25105 |
|
25106 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25107 |
|
25108 |
|
25109 | var multibyte = /[^\x00-\x7F]/;
|
25110 |
|
25111 |
|
25112 | function isMultibyte(str) {
|
25113 | (0, _assertString.default)(str);
|
25114 | return multibyte.test(str);
|
25115 | }
|
25116 |
|
25117 | module.exports = exports.default;
|
25118 | module.exports.default = exports.default;
|
25119 | },{"./util/assertString":226}],205:[function(require,module,exports){
|
25120 | "use strict";
|
25121 |
|
25122 | Object.defineProperty(exports, "__esModule", {
|
25123 | value: true
|
25124 | });
|
25125 | exports.default = isNumeric;
|
25126 |
|
25127 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25128 |
|
25129 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25130 |
|
25131 | var numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;
|
25132 | var numericNoSymbols = /^[0-9]+$/;
|
25133 |
|
25134 | function 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 |
|
25144 | module.exports = exports.default;
|
25145 | module.exports.default = exports.default;
|
25146 | },{"./util/assertString":226}],206:[function(require,module,exports){
|
25147 | "use strict";
|
25148 |
|
25149 | Object.defineProperty(exports, "__esModule", {
|
25150 | value: true
|
25151 | });
|
25152 | exports.default = isPort;
|
25153 |
|
25154 | var _isInt = _interopRequireDefault(require("./isInt"));
|
25155 |
|
25156 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25157 |
|
25158 | function isPort(str) {
|
25159 | return (0, _isInt.default)(str, {
|
25160 | min: 0,
|
25161 | max: 65535
|
25162 | });
|
25163 | }
|
25164 |
|
25165 | module.exports = exports.default;
|
25166 | module.exports.default = exports.default;
|
25167 | },{"./isInt":192}],207:[function(require,module,exports){
|
25168 | "use strict";
|
25169 |
|
25170 | Object.defineProperty(exports, "__esModule", {
|
25171 | value: true
|
25172 | });
|
25173 | exports.default = _default;
|
25174 | exports.locales = void 0;
|
25175 |
|
25176 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25177 |
|
25178 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25179 |
|
25180 |
|
25181 | var threeDigit = /^\d{3}$/;
|
25182 | var fourDigit = /^\d{4}$/;
|
25183 | var fiveDigit = /^\d{5}$/;
|
25184 | var sixDigit = /^\d{6}$/;
|
25185 | var 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 | };
|
25233 | var locales = Object.keys(patterns);
|
25234 | exports.locales = locales;
|
25235 |
|
25236 | function _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 |
|
25260 | Object.defineProperty(exports, "__esModule", {
|
25261 | value: true
|
25262 | });
|
25263 | exports.default = isRFC3339;
|
25264 |
|
25265 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25266 |
|
25267 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25268 |
|
25269 |
|
25270 | var dateFullYear = /[0-9]{4}/;
|
25271 | var dateMonth = /(0[1-9]|1[0-2])/;
|
25272 | var dateMDay = /([12]\d|0[1-9]|3[01])/;
|
25273 | var timeHour = /([01][0-9]|2[0-3])/;
|
25274 | var timeMinute = /[0-5][0-9]/;
|
25275 | var timeSecond = /([0-5][0-9]|60)/;
|
25276 | var timeSecFrac = /(\.[0-9]+)?/;
|
25277 | var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
|
25278 | var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
|
25279 | var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
|
25280 | var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
|
25281 | var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
|
25282 | var rfc3339 = new RegExp("".concat(fullDate.source, "[ tT]").concat(fullTime.source));
|
25283 |
|
25284 | function isRFC3339(str) {
|
25285 | (0, _assertString.default)(str);
|
25286 | return rfc3339.test(str);
|
25287 | }
|
25288 |
|
25289 | module.exports = exports.default;
|
25290 | module.exports.default = exports.default;
|
25291 | },{"./util/assertString":226}],209:[function(require,module,exports){
|
25292 | "use strict";
|
25293 |
|
25294 | Object.defineProperty(exports, "__esModule", {
|
25295 | value: true
|
25296 | });
|
25297 | exports.default = isSurrogatePair;
|
25298 |
|
25299 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25300 |
|
25301 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25302 |
|
25303 | var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
25304 |
|
25305 | function isSurrogatePair(str) {
|
25306 | (0, _assertString.default)(str);
|
25307 | return surrogatePair.test(str);
|
25308 | }
|
25309 |
|
25310 | module.exports = exports.default;
|
25311 | module.exports.default = exports.default;
|
25312 | },{"./util/assertString":226}],210:[function(require,module,exports){
|
25313 | "use strict";
|
25314 |
|
25315 | Object.defineProperty(exports, "__esModule", {
|
25316 | value: true
|
25317 | });
|
25318 | exports.default = isURL;
|
25319 |
|
25320 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25321 |
|
25322 | var _isFQDN = _interopRequireDefault(require("./isFQDN"));
|
25323 |
|
25324 | var _isIP = _interopRequireDefault(require("./isIP"));
|
25325 |
|
25326 | var _merge = _interopRequireDefault(require("./util/merge"));
|
25327 |
|
25328 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25329 |
|
25330 | var 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 | };
|
25340 | var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
|
25341 |
|
25342 | function isRegExp(obj) {
|
25343 | return Object.prototype.toString.call(obj) === '[object RegExp]';
|
25344 | }
|
25345 |
|
25346 | function 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 |
|
25358 | function 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 |
|
25463 | module.exports = exports.default;
|
25464 | module.exports.default = exports.default;
|
25465 | },{"./isFQDN":174,"./isIP":181,"./util/assertString":226,"./util/merge":228}],211:[function(require,module,exports){
|
25466 | "use strict";
|
25467 |
|
25468 | Object.defineProperty(exports, "__esModule", {
|
25469 | value: true
|
25470 | });
|
25471 | exports.default = isUUID;
|
25472 |
|
25473 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25474 |
|
25475 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25476 |
|
25477 | var 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 |
|
25484 | function 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 |
|
25491 | module.exports = exports.default;
|
25492 | module.exports.default = exports.default;
|
25493 | },{"./util/assertString":226}],212:[function(require,module,exports){
|
25494 | "use strict";
|
25495 |
|
25496 | Object.defineProperty(exports, "__esModule", {
|
25497 | value: true
|
25498 | });
|
25499 | exports.default = isUppercase;
|
25500 |
|
25501 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25502 |
|
25503 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25504 |
|
25505 | function isUppercase(str) {
|
25506 | (0, _assertString.default)(str);
|
25507 | return str === str.toUpperCase();
|
25508 | }
|
25509 |
|
25510 | module.exports = exports.default;
|
25511 | module.exports.default = exports.default;
|
25512 | },{"./util/assertString":226}],213:[function(require,module,exports){
|
25513 | "use strict";
|
25514 |
|
25515 | Object.defineProperty(exports, "__esModule", {
|
25516 | value: true
|
25517 | });
|
25518 | exports.default = isVariableWidth;
|
25519 |
|
25520 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25521 |
|
25522 | var _isFullWidth = require("./isFullWidth");
|
25523 |
|
25524 | var _isHalfWidth = require("./isHalfWidth");
|
25525 |
|
25526 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25527 |
|
25528 | function isVariableWidth(str) {
|
25529 | (0, _assertString.default)(str);
|
25530 | return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
|
25531 | }
|
25532 |
|
25533 | module.exports = exports.default;
|
25534 | module.exports.default = exports.default;
|
25535 | },{"./isFullWidth":176,"./isHalfWidth":177,"./util/assertString":226}],214:[function(require,module,exports){
|
25536 | "use strict";
|
25537 |
|
25538 | Object.defineProperty(exports, "__esModule", {
|
25539 | value: true
|
25540 | });
|
25541 | exports.default = isWhitelisted;
|
25542 |
|
25543 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25544 |
|
25545 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25546 |
|
25547 | function 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 |
|
25559 | module.exports = exports.default;
|
25560 | module.exports.default = exports.default;
|
25561 | },{"./util/assertString":226}],215:[function(require,module,exports){
|
25562 | "use strict";
|
25563 |
|
25564 | Object.defineProperty(exports, "__esModule", {
|
25565 | value: true
|
25566 | });
|
25567 | exports.default = ltrim;
|
25568 |
|
25569 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25570 |
|
25571 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25572 |
|
25573 | function 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 |
|
25579 | module.exports = exports.default;
|
25580 | module.exports.default = exports.default;
|
25581 | },{"./util/assertString":226}],216:[function(require,module,exports){
|
25582 | "use strict";
|
25583 |
|
25584 | Object.defineProperty(exports, "__esModule", {
|
25585 | value: true
|
25586 | });
|
25587 | exports.default = matches;
|
25588 |
|
25589 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25590 |
|
25591 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25592 |
|
25593 | function 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 |
|
25603 | module.exports = exports.default;
|
25604 | module.exports.default = exports.default;
|
25605 | },{"./util/assertString":226}],217:[function(require,module,exports){
|
25606 | "use strict";
|
25607 |
|
25608 | Object.defineProperty(exports, "__esModule", {
|
25609 | value: true
|
25610 | });
|
25611 | exports.default = normalizeEmail;
|
25612 |
|
25613 | var _merge = _interopRequireDefault(require("./util/merge"));
|
25614 |
|
25615 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25616 |
|
25617 | var default_normalize_email_options = {
|
25618 |
|
25619 |
|
25620 |
|
25621 |
|
25622 | all_lowercase: true,
|
25623 |
|
25624 |
|
25625 | gmail_lowercase: true,
|
25626 |
|
25627 | gmail_remove_dots: true,
|
25628 |
|
25629 | gmail_remove_subaddress: true,
|
25630 |
|
25631 | gmail_convert_googlemaildotcom: true,
|
25632 |
|
25633 |
|
25634 | outlookdotcom_lowercase: true,
|
25635 |
|
25636 | outlookdotcom_remove_subaddress: true,
|
25637 |
|
25638 |
|
25639 | yahoo_lowercase: true,
|
25640 |
|
25641 | yahoo_remove_subaddress: true,
|
25642 |
|
25643 |
|
25644 | yandex_lowercase: true,
|
25645 |
|
25646 |
|
25647 | icloud_lowercase: true,
|
25648 |
|
25649 | icloud_remove_subaddress: true
|
25650 | };
|
25651 |
|
25652 | var icloud_domains = ['icloud.com', 'me.com'];
|
25653 |
|
25654 |
|
25655 |
|
25656 |
|
25657 | var 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'];
|
25658 |
|
25659 |
|
25660 | var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com'];
|
25661 |
|
25662 | var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru'];
|
25663 |
|
25664 | function dotsReplacer(match) {
|
25665 | if (match.length > 1) {
|
25666 | return match;
|
25667 | }
|
25668 |
|
25669 | return '';
|
25670 | }
|
25671 |
|
25672 | function 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];
|
25678 |
|
25679 | parts[1] = parts[1].toLowerCase();
|
25680 |
|
25681 | if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
|
25682 |
|
25683 | if (options.gmail_remove_subaddress) {
|
25684 | parts[0] = parts[0].split('+')[0];
|
25685 | }
|
25686 |
|
25687 | if (options.gmail_remove_dots) {
|
25688 |
|
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 |
|
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 |
|
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 |
|
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';
|
25747 | } else if (options.all_lowercase) {
|
25748 |
|
25749 | parts[0] = parts[0].toLowerCase();
|
25750 | }
|
25751 |
|
25752 | return parts.join('@');
|
25753 | }
|
25754 |
|
25755 | module.exports = exports.default;
|
25756 | module.exports.default = exports.default;
|
25757 | },{"./util/merge":228}],218:[function(require,module,exports){
|
25758 | "use strict";
|
25759 |
|
25760 | Object.defineProperty(exports, "__esModule", {
|
25761 | value: true
|
25762 | });
|
25763 | exports.default = rtrim;
|
25764 |
|
25765 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25766 |
|
25767 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25768 |
|
25769 | function 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 |
|
25781 | module.exports = exports.default;
|
25782 | module.exports.default = exports.default;
|
25783 | },{"./util/assertString":226}],219:[function(require,module,exports){
|
25784 | "use strict";
|
25785 |
|
25786 | Object.defineProperty(exports, "__esModule", {
|
25787 | value: true
|
25788 | });
|
25789 | exports.default = stripLow;
|
25790 |
|
25791 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25792 |
|
25793 | var _blacklist = _interopRequireDefault(require("./blacklist"));
|
25794 |
|
25795 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25796 |
|
25797 | function 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 |
|
25803 | module.exports = exports.default;
|
25804 | module.exports.default = exports.default;
|
25805 | },{"./blacklist":155,"./util/assertString":226}],220:[function(require,module,exports){
|
25806 | "use strict";
|
25807 |
|
25808 | Object.defineProperty(exports, "__esModule", {
|
25809 | value: true
|
25810 | });
|
25811 | exports.default = toBoolean;
|
25812 |
|
25813 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25814 |
|
25815 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25816 |
|
25817 | function 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 |
|
25827 | module.exports = exports.default;
|
25828 | module.exports.default = exports.default;
|
25829 | },{"./util/assertString":226}],221:[function(require,module,exports){
|
25830 | "use strict";
|
25831 |
|
25832 | Object.defineProperty(exports, "__esModule", {
|
25833 | value: true
|
25834 | });
|
25835 | exports.default = toDate;
|
25836 |
|
25837 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25838 |
|
25839 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25840 |
|
25841 | function toDate(date) {
|
25842 | (0, _assertString.default)(date);
|
25843 | date = Date.parse(date);
|
25844 | return !isNaN(date) ? new Date(date) : null;
|
25845 | }
|
25846 |
|
25847 | module.exports = exports.default;
|
25848 | module.exports.default = exports.default;
|
25849 | },{"./util/assertString":226}],222:[function(require,module,exports){
|
25850 | "use strict";
|
25851 |
|
25852 | Object.defineProperty(exports, "__esModule", {
|
25853 | value: true
|
25854 | });
|
25855 | exports.default = toFloat;
|
25856 |
|
25857 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25858 |
|
25859 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25860 |
|
25861 | function toFloat(str) {
|
25862 | (0, _assertString.default)(str);
|
25863 | return parseFloat(str);
|
25864 | }
|
25865 |
|
25866 | module.exports = exports.default;
|
25867 | module.exports.default = exports.default;
|
25868 | },{"./util/assertString":226}],223:[function(require,module,exports){
|
25869 | "use strict";
|
25870 |
|
25871 | Object.defineProperty(exports, "__esModule", {
|
25872 | value: true
|
25873 | });
|
25874 | exports.default = toInt;
|
25875 |
|
25876 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25877 |
|
25878 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25879 |
|
25880 | function toInt(str, radix) {
|
25881 | (0, _assertString.default)(str);
|
25882 | return parseInt(str, radix || 10);
|
25883 | }
|
25884 |
|
25885 | module.exports = exports.default;
|
25886 | module.exports.default = exports.default;
|
25887 | },{"./util/assertString":226}],224:[function(require,module,exports){
|
25888 | "use strict";
|
25889 |
|
25890 | Object.defineProperty(exports, "__esModule", {
|
25891 | value: true
|
25892 | });
|
25893 | exports.default = trim;
|
25894 |
|
25895 | var _rtrim = _interopRequireDefault(require("./rtrim"));
|
25896 |
|
25897 | var _ltrim = _interopRequireDefault(require("./ltrim"));
|
25898 |
|
25899 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25900 |
|
25901 | function trim(str, chars) {
|
25902 | return (0, _rtrim.default)((0, _ltrim.default)(str, chars), chars);
|
25903 | }
|
25904 |
|
25905 | module.exports = exports.default;
|
25906 | module.exports.default = exports.default;
|
25907 | },{"./ltrim":215,"./rtrim":218}],225:[function(require,module,exports){
|
25908 | "use strict";
|
25909 |
|
25910 | Object.defineProperty(exports, "__esModule", {
|
25911 | value: true
|
25912 | });
|
25913 | exports.default = unescape;
|
25914 |
|
25915 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
25916 |
|
25917 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25918 |
|
25919 | function unescape(str) {
|
25920 | (0, _assertString.default)(str);
|
25921 | return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`');
|
25922 | }
|
25923 |
|
25924 | module.exports = exports.default;
|
25925 | module.exports.default = exports.default;
|
25926 | },{"./util/assertString":226}],226:[function(require,module,exports){
|
25927 | "use strict";
|
25928 |
|
25929 | Object.defineProperty(exports, "__esModule", {
|
25930 | value: true
|
25931 | });
|
25932 | exports.default = assertString;
|
25933 |
|
25934 | function _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 |
|
25936 | function 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 |
|
25958 | module.exports = exports.default;
|
25959 | module.exports.default = exports.default;
|
25960 | },{}],227:[function(require,module,exports){
|
25961 | "use strict";
|
25962 |
|
25963 | Object.defineProperty(exports, "__esModule", {
|
25964 | value: true
|
25965 | });
|
25966 | exports.default = void 0;
|
25967 |
|
25968 | var includes = function includes(arr, val) {
|
25969 | return arr.some(function (arrVal) {
|
25970 | return val === arrVal;
|
25971 | });
|
25972 | };
|
25973 |
|
25974 | var _default = includes;
|
25975 | exports.default = _default;
|
25976 | module.exports = exports.default;
|
25977 | module.exports.default = exports.default;
|
25978 | },{}],228:[function(require,module,exports){
|
25979 | "use strict";
|
25980 |
|
25981 | Object.defineProperty(exports, "__esModule", {
|
25982 | value: true
|
25983 | });
|
25984 | exports.default = merge;
|
25985 |
|
25986 | function 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 |
|
25999 | module.exports = exports.default;
|
26000 | module.exports.default = exports.default;
|
26001 | },{}],229:[function(require,module,exports){
|
26002 | "use strict";
|
26003 |
|
26004 | Object.defineProperty(exports, "__esModule", {
|
26005 | value: true
|
26006 | });
|
26007 | exports.default = toString;
|
26008 |
|
26009 | function _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 |
|
26011 | function 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 |
|
26025 | module.exports = exports.default;
|
26026 | module.exports.default = exports.default;
|
26027 | },{}],230:[function(require,module,exports){
|
26028 | "use strict";
|
26029 |
|
26030 | Object.defineProperty(exports, "__esModule", {
|
26031 | value: true
|
26032 | });
|
26033 | exports.default = whitelist;
|
26034 |
|
26035 | var _assertString = _interopRequireDefault(require("./util/assertString"));
|
26036 |
|
26037 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26038 |
|
26039 | function whitelist(str, chars) {
|
26040 | (0, _assertString.default)(str);
|
26041 | return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), '');
|
26042 | }
|
26043 |
|
26044 | module.exports = exports.default;
|
26045 | module.exports.default = exports.default;
|
26046 | },{"./util/assertString":226}],231:[function(require,module,exports){
|
26047 | module.exports = extend
|
26048 |
|
26049 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
26050 |
|
26051 | function 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 |
|
26070 | module.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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
26131 |
|
26132 | var validator = require("validator");
|
26133 |
|
26134 | var FormatValidators = {
|
26135 | "date": function (date) {
|
26136 | if (typeof date !== "string") {
|
26137 | return true;
|
26138 | }
|
26139 |
|
26140 | var matches = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(date);
|
26141 | if (matches === null) {
|
26142 | return false;
|
26143 | }
|
26144 |
|
26145 |
|
26146 |
|
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 |
|
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 |
|
26166 |
|
26167 |
|
26168 |
|
26169 |
|
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 |
|
26187 |
|
26188 |
|
26189 |
|
26190 |
|
26191 |
|
26192 |
|
26193 |
|
26194 |
|
26195 |
|
26196 |
|
26197 |
|
26198 |
|
26199 |
|
26200 |
|
26201 |
|
26202 |
|
26203 |
|
26204 |
|
26205 |
|
26206 |
|
26207 |
|
26208 |
|
26209 |
|
26210 |
|
26211 |
|
26212 |
|
26213 |
|
26214 |
|
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 |
|
26219 | if (hostname.length > 255) { return false; }
|
26220 |
|
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 |
|
26250 |
|
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 |
|
26258 | module.exports = FormatValidators;
|
26259 |
|
26260 | },{"validator":153}],234:[function(require,module,exports){
|
26261 | "use strict";
|
26262 |
|
26263 | var FormatValidators = require("./FormatValidators"),
|
26264 | Report = require("./Report"),
|
26265 | Utils = require("./Utils");
|
26266 |
|
26267 | var JsonValidators = {
|
26268 | multipleOf: function (report, schema, json) {
|
26269 |
|
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 |
|
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 |
|
26294 | },
|
26295 | minimum: function (report, schema, json) {
|
26296 |
|
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 |
|
26312 | },
|
26313 | maxLength: function (report, schema, json) {
|
26314 |
|
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 |
|
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 |
|
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 |
|
26342 | if (!Array.isArray(json)) {
|
26343 | return;
|
26344 | }
|
26345 |
|
26346 |
|
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 () {
|
26354 |
|
26355 | },
|
26356 | maxItems: function (report, schema, json) {
|
26357 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
26427 | if (schema.properties === undefined) {
|
26428 | return JsonValidators.properties.call(this, report, schema, json);
|
26429 | }
|
26430 | },
|
26431 | properties: function (report, schema, json) {
|
26432 |
|
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 |
|
26440 | var s = Object.keys(json);
|
26441 |
|
26442 | var p = Object.keys(properties);
|
26443 |
|
26444 | var pp = Object.keys(patternProperties);
|
26445 |
|
26446 | s = Utils.difference(s, p);
|
26447 |
|
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 |
|
26459 | if (s.length > 0) {
|
26460 |
|
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 |
|
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 |
|
26490 | var dependencyName = keys[idx];
|
26491 | if (json[dependencyName]) {
|
26492 | var dependencyDefinition = schema.dependencies[dependencyName];
|
26493 | if (Utils.whatIs(dependencyDefinition) === "object") {
|
26494 |
|
26495 | exports.validate.call(this, report, dependencyDefinition, json);
|
26496 | } else {
|
26497 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 () {
|
26595 |
|
26596 |
|
26597 | },
|
26598 | format: function (report, schema, json) {
|
26599 |
|
26600 | var formatValidatorFn = FormatValidators[schema.format];
|
26601 | if (typeof formatValidatorFn === "function") {
|
26602 | if (formatValidatorFn.length === 2) {
|
26603 |
|
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 |
|
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 |
|
26621 | var recurseArray = function (report, schema, json) {
|
26622 |
|
26623 |
|
26624 | var idx = json.length;
|
26625 |
|
26626 |
|
26627 |
|
26628 |
|
26629 |
|
26630 | if (Array.isArray(schema.items)) {
|
26631 |
|
26632 | while (idx--) {
|
26633 |
|
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 |
|
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 |
|
26651 |
|
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 |
|
26661 | var recurseObject = function (report, schema, json) {
|
26662 |
|
26663 |
|
26664 |
|
26665 |
|
26666 | var additionalProperties = schema.additionalProperties;
|
26667 | if (additionalProperties === true || additionalProperties === undefined) {
|
26668 | additionalProperties = {};
|
26669 | }
|
26670 |
|
26671 |
|
26672 | var p = schema.properties ? Object.keys(schema.properties) : [];
|
26673 |
|
26674 |
|
26675 | var pp = schema.patternProperties ? Object.keys(schema.patternProperties) : [];
|
26676 |
|
26677 |
|
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 |
|
26686 | var s = [];
|
26687 |
|
26688 |
|
26689 | if (p.indexOf(m) !== -1) {
|
26690 | s.push(schema.properties[m]);
|
26691 | }
|
26692 |
|
26693 |
|
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 |
|
26703 | if (s.length === 0 && additionalProperties !== false) {
|
26704 | s.push(additionalProperties);
|
26705 | }
|
26706 |
|
26707 |
|
26708 |
|
26709 |
|
26710 |
|
26711 |
|
26712 | idx2 = s.length;
|
26713 | while (idx2--) {
|
26714 | report.path.push(m);
|
26715 | exports.validate.call(this, report, s[idx2], propertyValue);
|
26716 |
|
26717 |
|
26718 |
|
26719 |
|
26720 | }
|
26721 | }
|
26722 | };
|
26723 |
|
26724 | exports.JsonValidators = JsonValidators;
|
26725 |
|
26726 |
|
26727 |
|
26728 |
|
26729 |
|
26730 |
|
26731 |
|
26732 | exports.validate = function (report, schema, json) {
|
26733 |
|
26734 | report.commonErrorMessage = "JSON_OBJECT_VALIDATION_FAILED";
|
26735 |
|
26736 |
|
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 |
|
26744 | var keys = Object.keys(schema);
|
26745 | if (keys.length === 0) {
|
26746 | return true;
|
26747 | }
|
26748 |
|
26749 |
|
26750 | var isRoot = false;
|
26751 | if (!report.rootSchema) {
|
26752 | report.rootSchema = schema;
|
26753 | isRoot = true;
|
26754 | }
|
26755 |
|
26756 |
|
26757 | if (schema.$ref !== undefined) {
|
26758 |
|
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 |
|
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 |
|
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 |
|
26809 | if (isRoot) {
|
26810 | report.rootSchema = undefined;
|
26811 | }
|
26812 |
|
26813 |
|
26814 | return report.errors.length === 0;
|
26815 |
|
26816 | };
|
26817 |
|
26818 | },{"./FormatValidators":233,"./Report":236,"./Utils":240}],235:[function(require,module,exports){
|
26819 |
|
26820 |
|
26821 | if (typeof Number.isFinite !== "function") {
|
26822 | Number.isFinite = function isFinite(value) {
|
26823 |
|
26824 | if (typeof value !== "number") {
|
26825 | return false;
|
26826 | }
|
26827 |
|
26828 | if (value !== value || value === Infinity || value === -Infinity) {
|
26829 | return false;
|
26830 | }
|
26831 |
|
26832 | return true;
|
26833 | };
|
26834 | }
|
26835 |
|
26836 | },{}],236:[function(require,module,exports){
|
26837 | (function (process){
|
26838 | "use strict";
|
26839 |
|
26840 | var get = require("lodash.get");
|
26841 | var Errors = require("./Errors");
|
26842 | var Utils = require("./Utils");
|
26843 |
|
26844 | /**
|
26845 | * @class
|
26846 | *
|
26847 | * @param {Report|object} parentOrOptions
|
26848 | * @param {object} [reportOptions]
|
26849 | */
|
26850 | function 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 |
|
26864 |
|
26865 | this.path = [];
|
26866 | this.asyncTasks = [];
|
26867 |
|
26868 | this.rootSchema = undefined;
|
26869 | this.commonErrorMessage = undefined;
|
26870 | this.json = undefined;
|
26871 | }
|
26872 |
|
26873 |
|
26874 |
|
26875 |
|
26876 | Report.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 |
|
26886 |
|
26887 |
|
26888 |
|
26889 | Report.prototype.addAsyncTask = function (fn, args, asyncTaskResultProcessFn) {
|
26890 | this.asyncTasks.push([fn, args, asyncTaskResultProcessFn]);
|
26891 | };
|
26892 |
|
26893 |
|
26894 |
|
26895 |
|
26896 |
|
26897 |
|
26898 |
|
26899 |
|
26900 | Report.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 |
|
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 |
|
26950 |
|
26951 |
|
26952 |
|
26953 | Report.prototype.getPath = function (returnPathAsString) {
|
26954 | |
26955 |
|
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 |
|
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 |
|
26977 | Report.prototype.getSchemaId = function () {
|
26978 |
|
26979 | if (!this.rootSchema) {
|
26980 | return null;
|
26981 | }
|
26982 |
|
26983 |
|
26984 | var path = [];
|
26985 | if (this.parentReport) {
|
26986 | path = path.concat(this.parentReport.path);
|
26987 | }
|
26988 | path = path.concat(this.path);
|
26989 |
|
26990 |
|
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 |
|
26998 | return this.rootSchema.id;
|
26999 | };
|
27000 |
|
27001 |
|
27002 |
|
27003 |
|
27004 |
|
27005 |
|
27006 |
|
27007 |
|
27008 | Report.prototype.hasError = function (errorCode, params) {
|
27009 | var idx = this.errors.length;
|
27010 | while (idx--) {
|
27011 | if (this.errors[idx].code === errorCode) {
|
27012 |
|
27013 | var match = true;
|
27014 |
|
27015 |
|
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 |
|
27024 | if (match) { return match; }
|
27025 | }
|
27026 | }
|
27027 | return false;
|
27028 | };
|
27029 |
|
27030 |
|
27031 |
|
27032 |
|
27033 |
|
27034 |
|
27035 |
|
27036 |
|
27037 |
|
27038 |
|
27039 | Report.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 |
|
27045 | Report.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 |
|
27059 |
|
27060 |
|
27061 |
|
27062 |
|
27063 |
|
27064 |
|
27065 |
|
27066 | Report.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 |
|
27125 | module.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 |
|
27132 | var isequal = require("lodash.isequal");
|
27133 | var Report = require("./Report");
|
27134 | var SchemaCompilation = require("./SchemaCompilation");
|
27135 | var SchemaValidation = require("./SchemaValidation");
|
27136 | var Utils = require("./Utils");
|
27137 |
|
27138 | function decodeJSONPointer(str) {
|
27139 |
|
27140 | return decodeURIComponent(str).replace(/~[0-1]/g, function (x) {
|
27141 | return x === "~1" ? "/" : "~";
|
27142 | });
|
27143 | }
|
27144 |
|
27145 | function getRemotePath(uri) {
|
27146 | var io = uri.indexOf("#");
|
27147 | return io === -1 ? uri : uri.slice(0, io);
|
27148 | }
|
27149 |
|
27150 | function getQueryPath(uri) {
|
27151 | var io = uri.indexOf("#");
|
27152 | var res = io === -1 ? undefined : uri.slice(io + 1);
|
27153 |
|
27154 |
|
27155 | return res;
|
27156 | }
|
27157 |
|
27158 | function findId(schema, id) {
|
27159 |
|
27160 | if (typeof schema !== "object" || schema === null) {
|
27161 | return;
|
27162 | }
|
27163 |
|
27164 |
|
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 |
|
27199 |
|
27200 |
|
27201 |
|
27202 |
|
27203 | exports.cacheSchemaByUri = function (uri, schema) {
|
27204 | var remotePath = getRemotePath(uri);
|
27205 | if (remotePath) {
|
27206 | this.cache[remotePath] = schema;
|
27207 | }
|
27208 | };
|
27209 |
|
27210 |
|
27211 |
|
27212 |
|
27213 |
|
27214 |
|
27215 |
|
27216 | exports.removeFromCacheByUri = function (uri) {
|
27217 | var remotePath = getRemotePath(uri);
|
27218 | if (remotePath) {
|
27219 | delete this.cache[remotePath];
|
27220 | }
|
27221 | };
|
27222 |
|
27223 |
|
27224 |
|
27225 |
|
27226 |
|
27227 |
|
27228 |
|
27229 | exports.checkCacheForUri = function (uri) {
|
27230 | var remotePath = getRemotePath(uri);
|
27231 | return remotePath ? this.cache[remotePath] != null : false;
|
27232 | };
|
27233 |
|
27234 | exports.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 |
|
27244 | exports.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 |
|
27252 | var schema = Utils.cloneDeep(key);
|
27253 | this.referenceCache.push([key, schema]);
|
27254 | return schema;
|
27255 | };
|
27256 |
|
27257 | exports.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 |
|
27264 | var compileRemote = result !== root;
|
27265 |
|
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 |
|
27275 |
|
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) {
|
27300 | result = findId(result, key);
|
27301 | } else {
|
27302 | result = result[key];
|
27303 | }
|
27304 | }
|
27305 | }
|
27306 |
|
27307 | return result;
|
27308 | };
|
27309 |
|
27310 | exports.getRemotePath = getRemotePath;
|
27311 |
|
27312 | },{"./Report":236,"./SchemaCompilation":238,"./SchemaValidation":239,"./Utils":240,"lodash.isequal":121}],238:[function(require,module,exports){
|
27313 | "use strict";
|
27314 |
|
27315 | var Report = require("./Report");
|
27316 | var SchemaCache = require("./SchemaCache");
|
27317 | var Utils = require("./Utils");
|
27318 |
|
27319 | function 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 |
|
27349 | function 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 |
|
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 |
|
27406 | var compileArrayOfSchemasLoop = function (mainReport, arr) {
|
27407 | var idx = arr.length,
|
27408 | compiledCount = 0;
|
27409 |
|
27410 | while (idx--) {
|
27411 |
|
27412 |
|
27413 | var report = new Report(mainReport);
|
27414 | var isValid = exports.compileSchema.call(this, report, arr[idx]);
|
27415 | if (isValid) { compiledCount++; }
|
27416 |
|
27417 |
|
27418 | mainReport.errors = mainReport.errors.concat(report.errors);
|
27419 |
|
27420 | }
|
27421 |
|
27422 | return compiledCount;
|
27423 | };
|
27424 |
|
27425 | function 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 |
|
27435 | var compileArrayOfSchemas = function (report, arr) {
|
27436 |
|
27437 | var compiled = 0,
|
27438 | lastLoopCompiled;
|
27439 |
|
27440 | do {
|
27441 |
|
27442 |
|
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 |
|
27451 | lastLoopCompiled = compiled;
|
27452 |
|
27453 |
|
27454 | compiled = compileArrayOfSchemasLoop.call(this, report, arr);
|
27455 |
|
27456 |
|
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 |
|
27467 | refObj.obj["__" + refObj.key + "Resolved"] = response;
|
27468 |
|
27469 | sch.__$missingReferences.splice(idx2, 1);
|
27470 | }
|
27471 | }
|
27472 | if (sch.__$missingReferences.length === 0) {
|
27473 | delete sch.__$missingReferences;
|
27474 | }
|
27475 | }
|
27476 | }
|
27477 |
|
27478 |
|
27479 | } while (compiled !== arr.length && compiled !== lastLoopCompiled);
|
27480 |
|
27481 | return report.isValid();
|
27482 |
|
27483 | };
|
27484 |
|
27485 | exports.compileSchema = function (report, schema) {
|
27486 |
|
27487 | report.commonErrorMessage = "SCHEMA_COMPILATION_FAILED";
|
27488 |
|
27489 |
|
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 |
|
27500 | if (Array.isArray(schema)) {
|
27501 | return compileArrayOfSchemas.call(this, report, schema);
|
27502 | }
|
27503 |
|
27504 |
|
27505 | if (schema.__$compiled && schema.id && SchemaCache.checkCacheForUri.call(this, schema.id) === false) {
|
27506 | schema.__$compiled = undefined;
|
27507 | }
|
27508 |
|
27509 |
|
27510 | if (schema.__$compiled) {
|
27511 | return true;
|
27512 | }
|
27513 |
|
27514 | if (schema.id && typeof schema.id === "string") {
|
27515 |
|
27516 | SchemaCache.cacheSchemaByUri.call(this, schema.id, schema);
|
27517 | }
|
27518 |
|
27519 |
|
27520 | var isRoot = false;
|
27521 | if (!report.rootSchema) {
|
27522 | report.rootSchema = schema;
|
27523 | isRoot = true;
|
27524 | }
|
27525 |
|
27526 |
|
27527 | var isValidExceptReferences = report.isValid();
|
27528 | delete schema.__$missingReferences;
|
27529 |
|
27530 |
|
27531 | var refs = collectReferences.call(this, schema),
|
27532 | idx = refs.length;
|
27533 | while (idx--) {
|
27534 |
|
27535 | var refObj = refs[idx];
|
27536 | var response = SchemaCache.getSchemaByUri.call(this, report, refObj.ref, schema);
|
27537 |
|
27538 |
|
27539 | if (!response) {
|
27540 | var schemaReader = this.getSchemaReader();
|
27541 | if (schemaReader) {
|
27542 |
|
27543 | var s = schemaReader(refObj.ref);
|
27544 | if (s) {
|
27545 |
|
27546 | s.id = refObj.ref;
|
27547 |
|
27548 | var subreport = new Report(report);
|
27549 | if (!exports.compileSchema.call(this, subreport, s)) {
|
27550 |
|
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 |
|
27568 |
|
27569 | isDownloaded = SchemaCache.checkCacheForUri.call(this, refObj.ref);
|
27570 | }
|
27571 |
|
27572 | if (hasNotValid) {
|
27573 |
|
27574 | } else if (ignoreUnresolvableRemotes && isAbsolute) {
|
27575 |
|
27576 | } else if (isDownloaded) {
|
27577 |
|
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 |
|
27584 | if (isValidExceptReferences) {
|
27585 | schema.__$missingReferences = schema.__$missingReferences || [];
|
27586 | schema.__$missingReferences.push(refObj);
|
27587 | }
|
27588 | }
|
27589 | }
|
27590 |
|
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 |
|
27600 | SchemaCache.removeFromCacheByUri.call(this, schema.id);
|
27601 | }
|
27602 | }
|
27603 |
|
27604 |
|
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 |
|
27616 | var FormatValidators = require("./FormatValidators"),
|
27617 | JsonValidation = require("./JsonValidation"),
|
27618 | Report = require("./Report"),
|
27619 | Utils = require("./Utils");
|
27620 |
|
27621 | var SchemaValidators = {
|
27622 | $ref: function (report, schema) {
|
27623 |
|
27624 |
|
27625 | if (typeof schema.$ref !== "string") {
|
27626 | report.addError("KEYWORD_TYPE_EXPECTED", ["$ref", "string"]);
|
27627 | }
|
27628 | },
|
27629 | $schema: function (report, schema) {
|
27630 |
|
27631 | if (typeof schema.$schema !== "string") {
|
27632 | report.addError("KEYWORD_TYPE_EXPECTED", ["$schema", "string"]);
|
27633 | }
|
27634 | },
|
27635 | multipleOf: function (report, schema) {
|
27636 |
|
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 |
|
27645 | if (typeof schema.maximum !== "number") {
|
27646 | report.addError("KEYWORD_TYPE_EXPECTED", ["maximum", "number"]);
|
27647 | }
|
27648 | },
|
27649 | exclusiveMaximum: function (report, schema) {
|
27650 |
|
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 |
|
27659 | if (typeof schema.minimum !== "number") {
|
27660 | report.addError("KEYWORD_TYPE_EXPECTED", ["minimum", "number"]);
|
27661 | }
|
27662 | },
|
27663 | exclusiveMinimum: function (report, schema) {
|
27664 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
27732 | if (this.options.forceAdditional === true && schema.additionalItems === undefined && Array.isArray(schema.items)) {
|
27733 | report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalItems"]);
|
27734 | }
|
27735 |
|
27736 | if (this.options.assumeAdditional && schema.additionalItems === undefined && Array.isArray(schema.items)) {
|
27737 | schema.additionalItems = false;
|
27738 | }
|
27739 | },
|
27740 | maxItems: function (report, schema) {
|
27741 |
|
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 |
|
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 |
|
27758 | if (typeof schema.uniqueItems !== "boolean") {
|
27759 | report.addError("KEYWORD_TYPE_EXPECTED", ["uniqueItems", "boolean"]);
|
27760 | }
|
27761 | },
|
27762 | maxProperties: function (report, schema) {
|
27763 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
27827 | if (this.options.forceAdditional === true && schema.additionalProperties === undefined) {
|
27828 | report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalProperties"]);
|
27829 | }
|
27830 |
|
27831 | if (this.options.assumeAdditional && schema.additionalProperties === undefined) {
|
27832 | schema.additionalProperties = false;
|
27833 | }
|
27834 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
28095 | if (typeof schema.id !== "string") {
|
28096 | report.addError("KEYWORD_TYPE_EXPECTED", ["id", "string"]);
|
28097 | }
|
28098 | },
|
28099 | title: function (report, schema) {
|
28100 |
|
28101 | if (typeof schema.title !== "string") {
|
28102 | report.addError("KEYWORD_TYPE_EXPECTED", ["title", "string"]);
|
28103 | }
|
28104 | },
|
28105 | description: function (report, schema) {
|
28106 |
|
28107 | if (typeof schema.description !== "string") {
|
28108 | report.addError("KEYWORD_TYPE_EXPECTED", ["description", "string"]);
|
28109 | }
|
28110 | },
|
28111 | "default": function (/* report, schema */) {
|
28112 |
|
28113 |
|
28114 | }
|
28115 | };
|
28116 |
|
28117 |
|
28118 |
|
28119 |
|
28120 |
|
28121 |
|
28122 |
|
28123 |
|
28124 | var 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 |
|
28135 |
|
28136 |
|
28137 | exports.validateSchema = function (report, schema) {
|
28138 |
|
28139 | report.commonErrorMessage = "SCHEMA_VALIDATION_FAILED";
|
28140 |
|
28141 |
|
28142 | if (Array.isArray(schema)) {
|
28143 | return validateArrayOfSchemas.call(this, report, schema);
|
28144 | }
|
28145 |
|
28146 |
|
28147 | if (schema.__$validated) {
|
28148 | return true;
|
28149 | }
|
28150 |
|
28151 |
|
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 |
|
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 |
|
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 |
|
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 |
|
28237 | require("core-js/es6/symbol");
|
28238 |
|
28239 | exports.jsonSymbol = Symbol.for("z-schema/json");
|
28240 |
|
28241 | exports.schemaSymbol = Symbol.for("z-schema/schema");
|
28242 |
|
28243 |
|
28244 |
|
28245 |
|
28246 |
|
28247 |
|
28248 | var sortedKeys = exports.sortedKeys = function (obj) {
|
28249 | return Object.keys(obj).sort();
|
28250 | };
|
28251 |
|
28252 |
|
28253 |
|
28254 |
|
28255 |
|
28256 |
|
28257 |
|
28258 | exports.isAbsoluteUri = function (uri) {
|
28259 | return /^https?:\/\//.test(uri);
|
28260 | };
|
28261 |
|
28262 |
|
28263 |
|
28264 |
|
28265 |
|
28266 |
|
28267 |
|
28268 | exports.isRelativeUri = function (uri) {
|
28269 |
|
28270 | return /.+#/.test(uri);
|
28271 | };
|
28272 |
|
28273 | exports.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";
|
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;
|
28302 |
|
28303 | };
|
28304 |
|
28305 |
|
28306 |
|
28307 |
|
28308 |
|
28309 |
|
28310 |
|
28311 |
|
28312 |
|
28313 | exports.areEqual = function areEqual(json1, json2, options) {
|
28314 |
|
28315 | options = options || {};
|
28316 | var caseInsensitiveComparison = options.caseInsensitiveComparison || false;
|
28317 |
|
28318 |
|
28319 |
|
28320 |
|
28321 |
|
28322 |
|
28323 |
|
28324 |
|
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 |
|
28338 | if (Array.isArray(json1) && Array.isArray(json2)) {
|
28339 |
|
28340 | if (json1.length !== json2.length) {
|
28341 | return false;
|
28342 | }
|
28343 |
|
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 |
|
28354 | if (exports.whatIs(json1) === "object" && exports.whatIs(json2) === "object") {
|
28355 |
|
28356 | var keys1 = sortedKeys(json1);
|
28357 | var keys2 = sortedKeys(json2);
|
28358 | if (!areEqual(keys1, keys2, { caseInsensitiveComparison: caseInsensitiveComparison })) {
|
28359 | return false;
|
28360 | }
|
28361 |
|
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 |
|
28377 |
|
28378 |
|
28379 |
|
28380 |
|
28381 | exports.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 |
|
28397 |
|
28398 |
|
28399 |
|
28400 |
|
28401 | exports.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 |
|
28413 | exports.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 |
|
28435 | exports.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 |
|
28469 |
|
28470 |
|
28471 |
|
28472 |
|
28473 |
|
28474 |
|
28475 |
|
28476 |
|
28477 |
|
28478 |
|
28479 |
|
28480 |
|
28481 |
|
28482 |
|
28483 |
|
28484 |
|
28485 | exports.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 |
|
28495 | extra = string.charCodeAt(counter++);
|
28496 | if ((extra & 0xFC00) == 0xDC00) {
|
28497 | output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
28498 | } else {
|
28499 |
|
28500 |
|
28501 | output.push(value);
|
28502 | counter--;
|
28503 | }
|
28504 | } else {
|
28505 | output.push(value);
|
28506 | }
|
28507 | }
|
28508 | return output;
|
28509 | };
|
28510 |
|
28511 |
|
28512 | },{"core-js/es6/symbol":12}],241:[function(require,module,exports){
|
28513 | (function (process){
|
28514 | "use strict";
|
28515 |
|
28516 | require("./Polyfills");
|
28517 | var get = require("lodash.get");
|
28518 | var Report = require("./Report");
|
28519 | var FormatValidators = require("./FormatValidators");
|
28520 | var JsonValidation = require("./JsonValidation");
|
28521 | var SchemaCache = require("./SchemaCache");
|
28522 | var SchemaCompilation = require("./SchemaCompilation");
|
28523 | var SchemaValidation = require("./SchemaValidation");
|
28524 | var Utils = require("./Utils");
|
28525 | var Draft4Schema = require("./schemas/schema.json");
|
28526 | var Draft4HyperSchema = require("./schemas/hyper-schema.json");
|
28527 |
|
28528 | /**
|
28529 | * default options
|
28530 | */
|
28531 | var defaultOptions = {
|
28532 |
|
28533 | asyncTimeout: 2000,
|
28534 |
|
28535 | forceAdditional: false,
|
28536 |
|
28537 | assumeAdditional: false,
|
28538 |
|
28539 | enumCaseInsensitiveComparison: false,
|
28540 |
|
28541 | forceItems: false,
|
28542 |
|
28543 | forceMinItems: false,
|
28544 |
|
28545 | forceMaxItems: false,
|
28546 |
|
28547 | forceMinLength: false,
|
28548 |
|
28549 | forceMaxLength: false,
|
28550 |
|
28551 | forceProperties: false,
|
28552 |
|
28553 | ignoreUnresolvableReferences: false,
|
28554 |
|
28555 | noExtraKeywords: false,
|
28556 |
|
28557 | noTypeless: false,
|
28558 |
|
28559 | noEmptyStrings: false,
|
28560 |
|
28561 | noEmptyArrays: false,
|
28562 |
|
28563 | strictUris: false,
|
28564 |
|
28565 | strictMode: false,
|
28566 |
|
28567 | reportPathAsArray: false,
|
28568 |
|
28569 | breakOnFirstError: true,
|
28570 |
|
28571 | pedanticCheck: false,
|
28572 |
|
28573 | ignoreUnknownFormats: false,
|
28574 |
|
28575 | customValidator: null
|
28576 | };
|
28577 |
|
28578 | function normalizeOptions(options) {
|
28579 | var normalized;
|
28580 |
|
28581 |
|
28582 | if (typeof options === "object") {
|
28583 | var keys = Object.keys(options),
|
28584 | idx = keys.length,
|
28585 | key;
|
28586 |
|
28587 |
|
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 |
|
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 |
|
28626 |
|
28627 |
|
28628 |
|
28629 | function ZSchema(options) {
|
28630 | this.cache = {};
|
28631 | this.referenceCache = [];
|
28632 | this.validateOptions = {};
|
28633 |
|
28634 | this.options = normalizeOptions(options);
|
28635 |
|
28636 |
|
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 |
|
28645 |
|
28646 |
|
28647 |
|
28648 |
|
28649 |
|
28650 | ZSchema.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 |
|
28664 |
|
28665 |
|
28666 |
|
28667 | ZSchema.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 |
|
28686 |
|
28687 |
|
28688 |
|
28689 |
|
28690 |
|
28691 |
|
28692 | ZSchema.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 |
|
28766 | this.lastReport = report;
|
28767 | return report.isValid();
|
28768 | };
|
28769 | ZSchema.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 | };
|
28779 | ZSchema.prototype.getLastErrors = function () {
|
28780 | return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : undefined;
|
28781 | };
|
28782 | ZSchema.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 | };
|
28800 | ZSchema.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 | };
|
28812 | ZSchema.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 | };
|
28825 | ZSchema.prototype.getResolvedSchema = function (schema) {
|
28826 | var report = new Report(this.options);
|
28827 | schema = SchemaCache.getSchema.call(this, report, schema);
|
28828 |
|
28829 |
|
28830 | schema = Utils.cloneDeep(schema);
|
28831 |
|
28832 | var visited = [];
|
28833 |
|
28834 |
|
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 |
|
28887 |
|
28888 |
|
28889 |
|
28890 | ZSchema.prototype.setSchemaReader = function (schemaReader) {
|
28891 | return ZSchema.setSchemaReader(schemaReader);
|
28892 | };
|
28893 |
|
28894 | ZSchema.prototype.getSchemaReader = function () {
|
28895 | return ZSchema.schemaReader;
|
28896 | };
|
28897 |
|
28898 | ZSchema.schemaReader = undefined;
|
28899 |
|
28900 |
|
28901 |
|
28902 | ZSchema.setSchemaReader = function (schemaReader) {
|
28903 | ZSchema.schemaReader = schemaReader;
|
28904 | };
|
28905 | ZSchema.registerFormat = function (formatName, validatorFunction) {
|
28906 | FormatValidators[formatName] = validatorFunction;
|
28907 | };
|
28908 | ZSchema.unregisterFormat = function (formatName) {
|
28909 | delete FormatValidators[formatName];
|
28910 | };
|
28911 | ZSchema.getRegisteredFormats = function () {
|
28912 | return Object.keys(FormatValidators);
|
28913 | };
|
28914 | ZSchema.getDefaultOptions = function () {
|
28915 | return Utils.cloneDeep(defaultOptions);
|
28916 | };
|
28917 |
|
28918 | ZSchema.schemaSymbol = Utils.schemaSymbol;
|
28919 |
|
28920 | ZSchema.jsonSymbol = Utils.jsonSymbol;
|
28921 |
|
28922 | module.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){
|
28927 | module.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){
|
29087 | module.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 |
|