js-yaml-concat-seqs
v1.0.1
Published
js-yaml concatenate / merge sequences / arrays
Downloads
12
Maintainers
Readme
js-yaml-concat-seqs
This js-yaml
type is inspired by Ingy döt Net comment in the original Yaml Issue #48
discussing merging sequences. He suggested that a tag is a valid option to denote merging of sequences, or how he called it !concat-seqs
. I took the type system from the original js-yaml
library and extended it with a one-line extension for the concat-seqs
function as proposed.
This is a lightweight library (literally 5 lines of code), without any external dependencies other than js-yaml
. Requires Node 11 for Array.prototype.flat()
to be available.
js-yaml extra type:
- !!concat-seqs [*seq1, ..., *seq2]
Installation
npm install js-yaml-concat-seqs
Usage
import yaml from "js-yaml";
import type from "js-yaml-concat-seqs";
const schema = yaml.DEFAULT_SCHEMA.extend([ type ]);
const src = `
- &seq1
- qux
- qox
- &seq2
- qix
- qax
- !!concat-seqs
- *seq1
- - foo
- bar
- *seq2
`;
console.log(yaml.load(src, { schema }));