Index: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/dumper.js |
diff --git a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/dumper.js b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/dumper.js |
index e562f3fa02353f1ac7e72224b9930bba383e7d61..6c93141f20c6e1e0f8c11e613fbcb5deda28d1ff 100644 |
--- a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/dumper.js |
+++ b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/dumper.js |
@@ -81,8 +81,8 @@ function compileStyleMap(schema, map) { |
type = schema.compiledTypeMap[tag]; |
- if (type && _hasOwnProperty.call(type.dumpStyleAliases, style)) { |
- style = type.dumpStyleAliases[style]; |
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) { |
+ style = type.styleAliases[style]; |
} |
result[tag] = style; |
@@ -126,6 +126,9 @@ function State(options) { |
this.tag = null; |
this.result = ''; |
+ |
+ this.duplicates = []; |
+ this.usedDuplicates = null; |
} |
@@ -139,7 +142,7 @@ function testImplicitResolving(state, str) { |
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { |
type = state.implicitTypes[index]; |
- if (type.loadResolver && type.loadResolver({ result: str })) { |
+ if (type.resolve(str)) { |
return true; |
} |
} |
@@ -378,19 +381,19 @@ function detectType(state, object, explicit) { |
for (index = 0, length = typeList.length; index < length; index += 1) { |
type = typeList[index]; |
- if ((type.dumpInstanceOf || type.dumpPredicate) && |
- (!type.dumpInstanceOf || (('object' === typeof object) && (object instanceof type.dumpInstanceOf))) && |
- (!type.dumpPredicate || type.dumpPredicate(object))) { |
+ if ((type.instanceOf || type.predicate) && |
+ (!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) && |
+ (!type.predicate || type.predicate(object))) { |
state.tag = explicit ? type.tag : '?'; |
- if (type.dumpRepresenter) { |
- style = state.styleMap[type.tag] || type.dumpDefaultStyle; |
+ if (type.represent) { |
+ style = state.styleMap[type.tag] || type.defaultStyle; |
- if ('[object Function]' === _toString.call(type.dumpRepresenter)) { |
- _result = type.dumpRepresenter(object, style); |
- } else if (_hasOwnProperty.call(type.dumpRepresenter, style)) { |
- _result = type.dumpRepresenter[style](object, style); |
+ if ('[object Function]' === _toString.call(type.represent)) { |
+ _result = type.represent(object, style); |
+ } else if (_hasOwnProperty.call(type.represent, style)) { |
+ _result = type.represent[style](object, style); |
} else { |
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); |
} |
@@ -426,40 +429,114 @@ function writeNode(state, level, object, block, compact) { |
compact = false; |
} |
- if ('[object Object]' === type) { |
- if (block && (0 !== Object.keys(state.dump).length)) { |
- writeBlockMapping(state, level, state.dump, compact); |
- } else { |
- writeFlowMapping(state, level, state.dump); |
+ var objectOrArray = '[object Object]' === type || '[object Array]' === type, |
+ duplicateIndex, |
+ duplicate; |
+ |
+ if (objectOrArray) { |
+ duplicateIndex = state.duplicates.indexOf(object); |
+ duplicate = duplicateIndex !== -1; |
+ } |
+ |
+ if (duplicate && state.usedDuplicates[duplicateIndex]) { |
+ state.dump = '*ref_' + duplicateIndex; |
+ } else { |
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { |
+ state.usedDuplicates[duplicateIndex] = true; |
} |
- } else if ('[object Array]' === type) { |
- if (block && (0 !== state.dump.length)) { |
- writeBlockSequence(state, level, state.dump, compact); |
+ if ('[object Object]' === type) { |
+ if (block && (0 !== Object.keys(state.dump).length)) { |
+ writeBlockMapping(state, level, state.dump, compact); |
+ if (duplicate) { |
+ state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump; |
+ } |
+ } else { |
+ writeFlowMapping(state, level, state.dump); |
+ if (duplicate) { |
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; |
+ } |
+ } |
+ } else if ('[object Array]' === type) { |
+ if (block && (0 !== state.dump.length)) { |
+ writeBlockSequence(state, level, state.dump, compact); |
+ if (duplicate) { |
+ state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump; |
+ } |
+ } else { |
+ writeFlowSequence(state, level, state.dump); |
+ if (duplicate) { |
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; |
+ } |
+ } |
+ } else if ('[object String]' === type) { |
+ if ('?' !== state.tag) { |
+ writeScalar(state, state.dump); |
+ } |
+ } else if (state.skipInvalid) { |
+ return false; |
} else { |
- writeFlowSequence(state, level, state.dump); |
+ throw new YAMLException('unacceptable kind of an object to dump ' + type); |
} |
- } else if ('[object String]' === type) { |
- if ('?' !== state.tag) { |
- writeScalar(state, state.dump); |
+ |
+ if (null !== state.tag && '?' !== state.tag) { |
+ state.dump = '!<' + state.tag + '> ' + state.dump; |
} |
- } else if (state.skipInvalid) { |
- return false; |
- } else { |
- throw new YAMLException('unacceptabe kind of an object to dump ' + type); |
} |
- if (null !== state.tag && '?' !== state.tag) { |
- state.dump = '!<' + state.tag + '> ' + state.dump; |
- } |
return true; |
} |
+function getDuplicateReferences(object, state) { |
+ var objects = [], |
+ duplicatesIndexes = [], |
+ index, |
+ length; |
+ |
+ inspectNode(object, objects, duplicatesIndexes); |
+ |
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { |
+ state.duplicates.push(objects[duplicatesIndexes[index]]); |
+ } |
+ state.usedDuplicates = new Array(length); |
+} |
+ |
+function inspectNode(object, objects, duplicatesIndexes) { |
+ var type = _toString.call(object), |
+ objectKeyList, |
+ index, |
+ length; |
+ |
+ if (null !== object && 'object' === typeof object) { |
+ index = objects.indexOf(object); |
+ if (-1 !== index) { |
+ if (-1 === duplicatesIndexes.indexOf(index)) { |
+ duplicatesIndexes.push(index); |
+ } |
+ } else { |
+ objects.push(object); |
+ |
+ if(Array.isArray(object)) { |
+ for (index = 0, length = object.length; index < length; index += 1) { |
+ inspectNode(object[index], objects, duplicatesIndexes); |
+ } |
+ } else { |
+ objectKeyList = Object.keys(object); |
+ |
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) { |
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); |
+ } |
+ } |
+ } |
+ } |
+} |
function dump(input, options) { |
options = options || {}; |
var state = new State(options); |
+ getDuplicateReferences(input, state); |
+ |
if (writeNode(state, 0, input, true, true)) { |
return state.dump + '\n'; |
} else { |