JSPM

js-yaml-concat-seqs

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q63386F
  • License MIT

js-yaml concatenate / merge sequences / arrays

Package Exports

  • js-yaml-concat-seqs
  • js-yaml-concat-seqs/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-yaml-concat-seqs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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