diff --git a/coverage.html b/coverage.html index d82a96e2..319277f1 100644 --- a/coverage.html +++ b/coverage.html @@ -611,7 +611,7 @@

Test Report

0
0
180
-
2260
+
2662
@@ -663,70 +663,70 @@

Test Report

alternatives x-alternatives - 165 + 162 2 alternatives no x-alternatives - 28 + 44 3 default `auth` settings get documentation page should not be restricted - 57 + 53 4 default `auth` settings get documentation page should be restricted 401 - 15 + 16 5 authentication get plug-in interface with bearer token - 15 + 21 6 authentication get plug-in interface without bearer token - 26 + 25 7 authentication get API interface with bearer token - 14 + 19 8 authentication get API interface with incorrect bearer token - 10 + 27 9 builder defaults for swagger root object properties - 16 + 19 10 builder set values for swagger root object properties - 17 + 18 11 @@ -740,70 +740,70 @@

Test Report

builder xProperties : false - 14 + 18 13 builder reuseDefinitions : true - 13 + 21 14 builder reuseDefinitions : false - 14 + 16 15 builder debug : true - 0 + 1 16 plugin basic cache - 21 + 38 17 plugin cache with generateTimeout - 13 + 17 18 plugin model cache using weakmap - 15 + 16 19 child-models child definitions models - 21 + 31 20 child-models object within an object - array within an array - 22 + 21 21 connections server connection a - 19 + 17 22 @@ -817,14 +817,14 @@

Test Report

connections server connection c - 1 + 2 24 debug log - Joi.object() with child properties - 1 + 0 25 @@ -845,70 +845,70 @@

Test Report

definitions payload with inline definition - 18 + 20 28 definitions override definition named Model - 16 + 20 29 definitions reuseDefinitions = false - 14 + 15 30 definitions test that optional array is not in swagger output - 15 + 13 31 definitions test that name changing for required - 12 + 14 32 dereference flatten with no references - 16 + 18 33 dereference dereferences error - 1 + 0 34 document another connection connectionLabel - 7 + 6 35 document another connection error select first connection - 6 + 9 36 file upload - 11 + 16 37 @@ -922,217 +922,217 @@

Test Report

file file type not fired on other meta properties - 12 + 14 39 filter filter by tags=a - 19 + 16 40 filter filter by tags=a,b,c,d - 14 + 17 41 filter filter by tags=a,c - 17 + 18 42 filter filter by tags=a,-b - 16 + 19 43 filter filter by tags=a,+b - 15 + 14 44 filter filter by tags=a,+c - 12 + 17 45 filter filter by tags=x - 12 + 18 46 info no info object passed - 14 + 21 47 info no info title property passed - 10 + 11 48 info min valid info object - 11 + 15 49 info full info object - 10 + 12 50 validation function not joi - 13 + 14 51 lout examples all routes parsed - 67 + 96 52 path summary and description - 13 + 58 53 path description as an array - 11 + 14 54 path route settting of consumes produces - 14 + 17 55 path override plug-in settting of consumes produces - 13 + 17 56 path auto "x-www-form-urlencoded" consumes with payloadType - 12 + 14 57 path rename a parameter - 11 + 14 58 path auto "multipart/form-data" consumes with { swaggerType: "file" } - 11 + 18 59 path auto "multipart/form-data" do not add two - 12 + 11 60 path auto "application/x-www-form-urlencoded" do not add two - 17 + 12 61 path a user set content-type header removes consumes - 12 + 14 62 path payloadType form - 13 + 14 63 path accept header - 12 + 15 64 path accept header - no emum - 13 + 17 65 path accept header - default first - 13 + 20 66 path accept header acceptToProduce set to false - 14 + 18 67 path path parameters {id}/{note?} - 12 + 13 68 path path parameters {a}/{b?} required overriden by JOI - 16 + 14 69 @@ -1146,28 +1146,28 @@

Test Report

path basePath trim tailing slash - 11 + 13 71 path path, basePath suppressing version fragment - 11 + 14 72 path route deprecated - 18 + 26 73 path custom operationId for code-gen apps - 12 + 16 74 @@ -1188,35 +1188,35 @@

Test Report

path stop emtpy formData object creating parameter - 11 + 12 repathed jsonPath url - 3 + 15 repathed documentationPath url - 24 + 23 repathed swaggerUIPath url - 27 + 28 77 plugin plug-in register no vision dependency - 7 + 6 78 @@ -1230,21 +1230,21 @@

Test Report

plugin plug-in register no options - 8 + 11 80 plugin plug-in register test - 9 + 12 81 plugin default jsonPath url - 10 + 14 82 @@ -1258,14 +1258,14 @@

Test Report

plugin default swaggerUIPath url - 31 + 37 84 plugin swaggerUIPath + extend.js remapping - 11 + 9 85 @@ -1279,133 +1279,133 @@

Test Report

plugin disable swagger UI - 12 + 6 87 plugin disable swagger UI overriden by documentationPage - 25 + 31 88 plugin should take the plugin route prefix into account when rendering the UI - 31 + 28 89 plugin payloadType = form global - 13 + 14 90 plugin payloadType = json global - 13 + 14 91 plugin pathPrefixSize global - 10 + 11 92 plugin expanded none - 11 + 12 93 plugin expanded list - 11 + 15 94 plugin expanded full - 10 + 17 95 plugin pass through of tags querystring - 28 + 25 96 proxies basePath option - 13 + 11 97 proxies schemes and host options - 10 + 17 98 proxies x-forwarded options - 10 + 16 99 proxies Azure Web Sites options - 11 + 12 100 proxies iisnode options - 13 + 19 101 proxies adding facade for proxy using route options 1 - 13 + 25 102 proxies adding facade for proxy using route options 2 - naming - 13 + 12 103 proxies adding facade for proxy using route options 3 - defination reuse - 16 + 14 104 proxies adding facade for proxy using route options 4 - defination name clash - 13 + 15 105 @@ -1426,35 +1426,35 @@

Test Report

responses using hapi response.status - 18 + 25 108 responses using hapi response.status without 200 - 15 + 14 109 responses using route base plugin override - object - 15 + 16 110 responses using route merging response and plugin override - 12 + 15 111 responses using route base plugin override - array - 23 + 17 112 @@ -1468,35 +1468,35 @@

Test Report

responses No ownProperty - 0 + 1 114 responses with same path but different method - 14 + 19 115 responses with deep labels - 12 + 13 116 responses array with required #249 - 14 + 17 117 responses replace example with x-example for response - 13 + 15 118 @@ -1510,21 +1510,21 @@

Test Report

responses using hapi response.schema and plugin mismatch - 14 + 16 120 responses using hapi response.schema and plugin mismatch - 20 + 25 121 responses using hapi response.schema and plugin mixed results - 17 + 18 122 @@ -1538,21 +1538,21 @@

Test Report

security passes through security objects for whole api - 17 + 16 124 security passes through security objects on routes - 18 + 19 125 security passes through x-keyPrefix - 14 + 13 126 @@ -1566,14 +1566,14 @@

Test Report

sort sort ordered path-method - 21 + 22 128 tags no tag objects passed - 12 + 16 129 @@ -1587,28 +1587,28 @@

Test Report

tags full tag object - 11 + 12 131 wildcard routes method * - 12 + 14 132 wildcard routes method array [GET, POST] - 11 + 15 133 group test groups tagging of paths - 16 + 20 134 @@ -1622,7 +1622,7 @@

Test Report

group getNameByPath 2 - 0 + 1 136 @@ -1643,7 +1643,7 @@

Test Report

group getNameByPath 5 - 1 + 0 139 @@ -1657,7 +1657,7 @@

Test Report

group getNameByPath with basePath = /v3/ - 0 + 1 141 @@ -1678,7 +1678,7 @@

Test Report

property - parse types - 1 + 0 144 @@ -1706,28 +1706,28 @@

Test Report

property - parse meta - 3 + 2 148 property - parse type string - 6 + 12 149 property - parse type date - 0 + 1 150 property - parse type date timestamp - 1 + 0 151 @@ -1741,42 +1741,42 @@

Test Report

property - parse type array - 5 + 4 153 property deep - parse structure with child labels - 1 + 0 154 property deep - parse structure with child description, notes, name etc - 12 + 16 155 joi extension - custom joi extension - 2 + 1 156 utilities isObject - 0 + 1 157 utilities isFunction - 1 + 0 158 @@ -1790,14 +1790,14 @@

Test Report

utilities hasProperties - 0 + 1 160 utilities deleteEmptyProperties - 5 + 0 161 @@ -1853,28 +1853,28 @@

Test Report

utilities toJoiObject - 1 + 0 169 utilities hasJoiMeta - 0 + 1 170 utilities getJoiMetaProperty - 1 + 0 171 utilities toTitleCase - 0 + 1 172 @@ -1888,14 +1888,14 @@

Test Report

utilities replaceInPath - 1 + 0 174 validate - log bad schema - 0 + 1 175 @@ -1925,8 +1925,8 @@

Test Report

Code Coverage Report

100%
-
2430
-
2430
+
2437
+
2437
0
@@ -11576,8 +11576,8 @@

lib/paths.js

lib/properties.js

100%
-
532
-
532
+
539
+
539
0
@@ -13225,2243 +13225,2285 @@

lib/properties.js

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -16969,7 +17011,7 @@

lib/utilities.js

- + diff --git a/lib/properties.js b/lib/properties.js index cd097cc4..4771178b 100644 --- a/lib/properties.js +++ b/lib/properties.js @@ -270,9 +270,16 @@ internals.properties.prototype.parseString = function (property, joiObj) { // add regex joiObj._tests.forEach((test) => { + // Joi post v10 + if (Utilities.isObject(test.arg) && test.arg.pattern) { + property.pattern = test.arg.pattern.toString(); + } + // Joi pre v10 + /* $lab:coverage:off$ */ if (Utilities.isRegex(test.arg)) { property.pattern = test.arg.toString(); } + /* $lab:coverage:on$ */ }); diff --git a/package.json b/package.json index f4afb15e..af32d345 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hapi-swagger", "description": "A swagger documentation UI generator plugin for hapi", - "version": "7.4.1", + "version": "7.5.0", "author": "Glenn Jones", "repository": { "type": "git", @@ -24,18 +24,18 @@ "handlebars": "^4.0.5", "hoek": "^4.0.1", "http-status": "^0.2.3", - "joi": "9.0.4", + "joi": "10.0.5", "json-schema-ref-parser": "^3.1.2", "swagger-parser": "^3.4.1" }, "devDependencies": { "blipp": "^2.3.0", "chalk": "^1.1.3", - "code": "^3.0.1", + "code": "^4.0.0", "coveralls": "^2.11.11", "good": "^7.0.1", "good-console": "^6.1.2", - "good-squeeze": "^4.0.0", + "good-squeeze": "^5.0.1", "h2o2": "^5.1.0", "hapi": "^16.0.1", "hapi-api-version": "^1.1.0", @@ -43,11 +43,11 @@ "hapi-auth-jwt2": "^7.0.1", "hapi-auth-basic": "^4.2.0", "inert": "^4.0.1", - "js2xmlparser": "^1.0.0", - "lab": "^10.9.0", + "js2xmlparser": "^2.0.2", + "lab": "^11.0.0", "swagger-client": "^2.1.14", "vision": "^4.0.1", - "wreck": "^8.0.0", + "wreck": "^10.0.0", "jsonwebtoken": "^7.1.9" }, "scripts": {
273 // Joi post v10
274 59 if (Utilities.isObject(test.arg) && test.arg.pattern) {
2753 property.pattern = test.arg.pattern.toString();
276 }
277 // Joi pre v10
278 /* $lab:coverage:off$ */
279 if (Utilities.isRegex(test.arg)) {
274280 4 property.pattern = test.arg.toString();
275281 }
276282 /* $lab:coverage:on$ */
283 });
277284
278285
279286 // add extended properties not part of openAPI spec
280287 251 if (this.settings.xProperties === true) {
281288 212 internals.convertRules(property, describe.rules, [
282289 'insensitive',
283290 'length'
284291 ], 'x-constraint');
285292
286293 212 internals.convertRules(property, describe.rules, [
287294 'creditCard',
288295 'alphanum',
289296 'token',
290297 'email',
291298 'ip',
292299 'uri',
293300 'guid',
294301 'hex',
295302 'hostname',
296303 'isoDate'
297304 ], 'x-format');
298305
299306 212 internals.convertRules(property, describe.rules, [
300307 'lowercase',
301308 'uppercase',
302309 'trim'
303310 ], 'x-convert');
304311 }
305312
306313 251 return property;
307314 };
308315
309316
310317 /**
311318 * parse number property
312319 *
313320 * @param {Object} property
314321 * @param {Object} joiObj
315322 * @return {Object}
316323 */
317324 1 internals.properties.prototype.parseNumber = function (property, joiObj) {
318325
319326 205 const describe = joiObj.describe();
320327 205 property.minimum = internals.getArgByName(describe.rules, 'min');
321328 205 property.maximum = internals.getArgByName(describe.rules, 'max');
322329 205 if (internals.hasPropertyByName(describe.rules, 'integer')) {
323330 5 property.type = 'integer';
324331 }
325332
326333 // add extended properties not part of openAPI spec
327334 205 if (this.settings.xProperties === true) {
328335 191 internals.convertRules(property, describe.rules, [
329336 'greater',
330337 'less',
331338 'precision',
332339 'multiple',
333340 'positive',
334341 'negative'
335342 ], 'x-constraint');
336343 }
337344
338345 205 return property;
339346 };
340347
341348
342349 /**
343350 * parse date property
344351 *
345352 * @param {Object} property
346353 * @param {Object} joiObj
347354 * @return {Object}
348355 */
349356 1 internals.properties.prototype.parseDate = function (property, joiObj) {
350357
351358 12 if (joiObj._flags.timestamp) {
352359 2 property.type = 'number';
353360 2 delete property.format;
354361 }
355362
356363 12 return property;
357364 };
358365
359366
360367 /**
361368 * parse object property
362369 *
363370 * @param {Object} property
364371 * @param {Object} joiObj
365372 * @param {String} name
366373 * @param {Boolean} useDefinitions
367374 * @param {Boolean} isAlt
368375 * @return {Object}
369376 */
370377 1 internals.properties.prototype.parseObject = function (property, joiObj, name, parameterType, useDefinitions, isAlt) {
371378
372379 230 property.properties = {};
373380 230 joiObj = joiObj._inner.children;
374381 230 joiObj.forEach((obj) => {
375382
376383 433 let keyName = obj.key;
377384 433 let itemName = obj.key;
378385 433 let joiChildObj = obj.schema;
379386 // get name form label if set
380387 433 if (Utilities.geJoiLabel(joiChildObj)) {
381388 22 itemName = Utilities.geJoiLabel(joiChildObj);
382389 }
383390 //name, joiObj, parent, parameterType, useDefinitions, isAlt
384391 433 property.properties[keyName] = this.parseProperty(itemName, joiChildObj, property, parameterType, useDefinitions, isAlt);
385392 // switch references if naming has changed
386393 433 if (keyName !== itemName) {
387394 18 property.required = Utilities.replaceValue(property.required, itemName, keyName);
388395 18 property.optional = Utilities.replaceValue(property.optional, itemName, keyName);
389396 }
390397 });
391398 230 property.name = name;
392399 230 return property;
393400 };
394401
395402
396403 /**
397404 * parse array property
398405 *
399406 * @param {Object} property
400407 * @param {Object} joiObj
401408 * @param {String} name
402409 * @param {String} parameterType,
403410 * @param {Boolean} useDefinitions
404411 * @param {Boolean} isAlt
405412 * @return {Object}
406413 */
407414 1 internals.properties.prototype.parseArray = function (property, joiObj, name, parameterType, useDefinitions, isAlt) {
408415
409416 44 const describe = joiObj.describe();
410417 44 property.minItems = internals.getArgByName(describe.rules, 'min');
411418 44 property.maxItems = internals.getArgByName(describe.rules, 'max');
412419
413420
414421 // add extended properties not part of openAPI spec
415422 44 if (this.settings.xProperties === true) {
416423 28 internals.convertRules(property, describe.rules, [
417424 'length',
418425 'unique'
419426 ], 'x-constraint');
420427
421428 28 if (describe.flags.sparse) {
422429 1 internals.addToPropertyObject(property, 'x-constraint', 'sparse', true);
423430 }
424431 28 if (describe.flags.single) {
425432 1 internals.addToPropertyObject(property, 'x-constraint', 'single', true);
426433 }
427434 }
428435
429436
430437 // default the items with type:string
431438 44 property.items = {
432439 'type': 'string'
433440 };
434441
435442 // set swaggers collectionFormat to one that works with hapi
436443 44 if (parameterType === 'query' || parameterType === 'formData') {
437444 5 property.collectionFormat = 'multi';
438445 }
439446
440447 // swagger appears to only support one array item type at a time, so grab the first one
441448 44 let arrayItemTypes = joiObj._inner.items; // joiObj._inner.inclusions;
442449 44 let arrayItem = Utilities.first(arrayItemTypes);
443450
444451 44 if (arrayItem) {
445452 // get name of item if it has one
446453 31 let itemName;
447454 31 if (Utilities.geJoiLabel(arrayItem)) {
448455 15 itemName = Utilities.geJoiLabel(arrayItem);
449456 }
450457
451458 //name, joiObj, parent, parameterType, useDefinitions, isAlt
452459 31 let arrayItemProperty = this.parseProperty(itemName, arrayItem, property, parameterType, useDefinitions, isAlt);
453460 31 if (this.simpleTypePropertyMap[arrayItem._type.toLowerCase()]) {
454461 // map simple types directly
455462 10 property.items = {};
456463 10 for (let key in arrayItemProperty) {
457464 14 property.items[key] = arrayItemProperty[key];
458465 }
459466 } else {
460467 21 property.items = arrayItemProperty;
461468 }
462469
463470 }
464471
465472 44 property.name = name;
466473 44 return property;
467474 };
468475
469476
470477 /**
471478 * parse alternatives property
472479 *
473480 * @param {Object} property
474481 * @param {Object} joiObj
475482 * @param {String} name
476483 * @param {String} parameterType
477484 * @param {Boolean} useDefinitions
478485 * @return {Object}
479486 */
480487 1 internals.properties.prototype.parseAlternatives = function (property, joiObj, name, parameterType, useDefinitions) {
481488
482489 // convert .try() alternatives structures
483490 21 if (Hoek.reach(joiObj, '_inner.matches.0.schema')) {
484491 // add first into definitionCollection
485492 11 let child = joiObj._inner.matches[0].schema;
486493 11 let childName = Utilities.geJoiLabel(joiObj);
487494 //name, joiObj, parent, parameterType, useDefinitions, isAlt
488495 11 property = this.parseProperty(childName, child, property, parameterType, useDefinitions, false);
489496
490497 // create the alternatives without appending to the definitionCollection
491498 11 if (this.settings.xProperties === true) {
492499 7 let altArray = joiObj._inner.matches.map((obj) => {
493500 16 let altName = (Utilities.geJoiLabel(obj.schema) || name);
494501 //name, joiObj, parent, parameterType, useDefinitions, isAlt
495502 16 return this.parseProperty(altName, obj.schema, property, parameterType, useDefinitions, true);
496503 });
497504 7 property['x-alternatives'] = Hoek.clone(altArray);
498505 }
499506 }
500507
501508 // convert .when() alternatives structures
502509 else {
503510 // add first into definitionCollection
504511 10 let child = joiObj._inner.matches[0].then;
505512 10 let childName = (Utilities.geJoiLabel(child) || name);
506513 //name, joiObj, parent, parameterType, useDefinitions, isAlt
507514 10 property = this.parseProperty(childName, child, property, parameterType, useDefinitions, false);
508515
509516 // create the alternatives without appending to the definitionCollection
510517 10 if (this.settings.xProperties === true) {
511518 6 let altArray = joiObj._inner.matches
512519 .reduce((res, obj) => {
513520 12 obj.then && res.push(obj.then);
514521 12 obj.otherwise && res.push(obj.otherwise);
515522 12 return res;
516523 }, [])
517524 .map((joiNewObj) => {
518525 16 let altName = (Utilities.geJoiLabel(joiNewObj) || name);
519526 16 return this.parseProperty(altName, joiNewObj, property, parameterType, useDefinitions, true);
520527 })
521528 .filter((obj) => obj);
522529 6 property['x-alternatives'] = Hoek.clone(altArray);
523530 }
524531 }
525532
526533 //if (!property.$ref && Utilities.geJoiLabel(joiObj)) {
527534 // property.name = Utilities.geJoiLabel(joiObj);
528535 //}
529536
530537 21 return property;
531538 };
532539
533540
534541 /**
535542 * selects the correct definition collection
536543 *
537544 * @param {Boolean} isAlt
538545 * @return {Object}
539546 */
540547 1 internals.properties.prototype.getDefinitionCollection = function (isAlt) {
541548
542549 175 return (isAlt === true) ? this.altDefinitionCollection : this.definitionCollection;
543550 };
544551
545552
546553 /**
547554 * selects the correct definition reference
548555 *
549556 * @param {Boolean} isAlt
550557 * @return {String}
551558 */
552559 1 internals.properties.prototype.getDefinitionRef = function (isAlt) {
553560
554561 175 return (isAlt === true) ? '#/x-alt-definitions/' : '#/definitions/';
555562 };
556563
557564
558565 /**
559566 * coverts rules into property objects
560567 *
561568 * @param {Object} property
562569 * @param {Array} rules
563570 * @param {Array} ruleNames
564571 * @param {String} groupName
565572 */
566573 1 internals.convertRules = function (property, rules, ruleNames, groupName) {
567574
568575 1538 ruleNames.forEach((ruleName) => {
569576 5065 internals.appendToPropertyObject(property, rules, groupName, ruleName);
570577 });
571578 };
572579
573580
574581 /**
575582 * appends a name item to object on a property
576583 *
577584 * @param {Object} property
578585 * @param {Array} rules
579586 * @param {String} groupName
580587 * @param {String} ruleName
581588 */
582589 1 internals.appendToPropertyObject = function (property, rules, groupName, ruleName) {
583590
584591 5065 if (internals.hasPropertyByName(rules, ruleName)) {
585592 56 let value = internals.getArgByName(rules, ruleName);
586593 56 if (Utilities.isObject(value) && Utilities.hasProperties(value) === false) {
587594 1 value = undefined;
588595 }
589596 56 internals.addToPropertyObject(property, groupName, ruleName, value);
590597 }
591598 };
592599
593600
594601 /**
595602 * add a name item to object on a property
596603 *
597604 * @param {Object} property
598605 * @param {String} groupName
599606 * @param {String} ruleName
600607 * @param {String} value
601608 */
602609 1 internals.addToPropertyObject = function (property, groupName, ruleName, value) {
603610
604611 58 if (!property[groupName]) {
605612 51 property[groupName] = {};
606613 }
607614 58 property[groupName][ruleName] = (value !== undefined) ? value : true;
608615 };
609616
610617
611618 /**
612619 * return the value of an item in array of object by name - structure [ { name: 'value', arg: 'value' } ]
613620 *
614621 * @param {Array} array
615622 * @param {String} name
616623 * @return {String || Undefined}
617624 */
618625 1 internals.getArgByName = function (array, name) {
619626
620627 1056 if (Array.isArray(array)) {
621628 206 let i = array.length;
622629 206 while (i--) {
623630 267 if (array[i].name === name) {
624631 76 return array[i].arg;
625632 }
626633 }
627634 }
628635 980 return undefined;
629636 };
630637
631638
632639 /**
633640 * return existance of an item in array of - structure [ { name: 'value' } ]
634641 *
635642 * @param {Array} array
636643 * @param {String} name
637644 * @return {Boolean}
638645 */
639646 1 internals.hasPropertyByName = function (array, name) {
640647
641648 5270 return array && array.some((obj) => {
642649
643650 960 return obj.name === name;
644651 });
645652 };
646653
15 81488207 return obj !== null && obj !== undefined && typeof obj === 'object' && !Array.isArray(obj);