From 9e06b6aadf1d134d27f2b1871762d72cfc519d4c Mon Sep 17 00:00:00 2001 From: Alexander Holland Date: Sat, 16 Nov 2019 11:20:08 +0100 Subject: [PATCH] Adds style option for nested sequence Each nested array will be in a new line if true - - 1 else - - 1 --- lib/js-yaml/dumper.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/js-yaml/dumper.js b/lib/js-yaml/dumper.js index f3d4fd93..d26badad 100644 --- a/lib/js-yaml/dumper.js +++ b/lib/js-yaml/dumper.js @@ -118,6 +118,7 @@ function State(options) { this.noRefs = options['noRefs'] || false; this.noCompatMode = options['noCompatMode'] || false; this.condenseFlow = options['condenseFlow'] || false; + this.nestedSeqBlocks = options['nestedSeqBlocks'] || false; this.implicitTypes = this.schema.compiledImplicit; this.explicitTypes = this.schema.compiledExplicit; @@ -550,6 +551,10 @@ function writeBlockSequence(state, level, object, compact) { _result += '- '; } + if (state.nestedSeqBlocks && Array.isArray(object[index])) { + _result += generateNextLine(state, level + 1); + } + _result += state.dump; } }