@stoplight/yaml
Advanced tools
Comparing version 3.1.0 to 3.1.1
{ | ||
"name": "@stoplight/yaml", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Useful functions when working with YAML.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -40,12 +40,21 @@ "use strict"; | ||
const container = {}; | ||
const seenKeys = []; | ||
const handleMergeKeys = options !== void 0 && options.mergeKeys === true; | ||
const handleDuplicates = (options !== void 0 && options.json === false) || duplicatedMappingKeys !== void 0; | ||
for (const mapping of node.mappings) { | ||
if (mapping.key.value in container) { | ||
if (options !== void 0 && options.json === false) { | ||
throw new Error('Duplicate YAML mapping key encountered'); | ||
const key = mapping.key.value; | ||
if (handleDuplicates && (!handleMergeKeys || key !== "<<")) { | ||
if (seenKeys.includes(mapping.key.value)) { | ||
if (options !== void 0 && options.json === false) { | ||
throw new Error('Duplicate YAML mapping key encountered'); | ||
} | ||
if (duplicatedMappingKeys !== void 0) { | ||
duplicatedMappingKeys.push(mapping.key); | ||
} | ||
} | ||
if (duplicatedMappingKeys !== void 0) { | ||
duplicatedMappingKeys.push(mapping.key); | ||
else { | ||
seenKeys.push(key); | ||
} | ||
} | ||
if (options !== void 0 && options.mergeKeys === true && mapping.key.value === "<<") { | ||
if (handleMergeKeys && key === "<<") { | ||
Object.assign(container, reduceMergeKeys(exports.walkAST(mapping.value, options, duplicatedMappingKeys))); | ||
@@ -52,0 +61,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54860
562