js-yaml-concat-seqs

1.0.1 • Public • Published

js-yaml-concat-seqs

CI NPM version

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 }));

Package Sidebar

Install

npm i js-yaml-concat-seqs

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

3.67 kB

Total Files

4

Last publish

Collaborators

  • kriskra