Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sap-ux/yaml

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap-ux/yaml - npm Package Compare versions

Comparing version 0.13.2 to 0.13.3

2

dist/yaml-document.d.ts

@@ -13,3 +13,3 @@ import type { YAMLMap } from 'yaml';

export declare class YamlDocument {
private document;
private documents;
/**

@@ -16,0 +16,0 @@ * Returns a new instance of YamlDocument.

@@ -52,7 +52,15 @@ "use strict";

constructor(serializedYaml) {
var _a;
this.document = yaml_1.default.parseDocument(serializedYaml);
if (((_a = this.document.errors) === null || _a === void 0 ? void 0 : _a.length) > 0) {
throw new errors_1.YAMLError(errors_1.errorTemplate.yamlParsing + '\n' + this.document.errors.map((e) => e.message).join(''), errors_1.errorCode.yamlParsing);
this.documents = yaml_1.default.parseAllDocuments(serializedYaml);
if (this.documents.length === 0) {
// this is done for backward compatibility when only single document yaml was supported.
// yaml.parseDocument('') creates a new document
// yaml.parseAll('') does not create a new document
this.documents.push(yaml_1.default.parseDocument(serializedYaml));
}
const docsWithErrors = this.documents.filter((doc) => doc.errors.length > 0);
if (docsWithErrors.length > 0) {
throw new errors_1.YAMLError(errors_1.errorTemplate.yamlParsing +
'\n' +
docsWithErrors.map((doc) => doc.errors.map((e) => e.message).join('')), errors_1.errorCode.yamlParsing);
}
}

@@ -79,3 +87,3 @@ /**

toString() {
return this.document.toString({ singleQuote: true });
return this.documents.map((d) => d.toString({ singleQuote: true })).join('');
}

@@ -94,6 +102,6 @@ /**

case 'beginning':
this.document.commentBefore = comment;
this.documents[0].commentBefore = comment;
break;
case 'end':
this.document.comment = comment;
this.documents[0].comment = comment;
break;

@@ -132,3 +140,3 @@ default:

const parentPath = pathArray.slice(0, -1);
const parentNode = this.document.getIn(parentPath);
const parentNode = this.documents[0].getIn(parentPath);
if (!parentNode && !createIntermediateKeys) {

@@ -139,7 +147,7 @@ // Not at root and we're not asked to create the intermediate keys

}
const newNode = this.document.createNode(value);
const newNode = this.documents[0].createNode(value);
if (comment) {
newNode.commentBefore = comment;
}
this.document.setIn(pathArray, newNode);
this.documents[0].setIn(pathArray, newNode);
return this;

@@ -162,3 +170,3 @@ }

// Create a copy to work to modify
const documentCopy = this.document.clone();
const documentCopy = this.documents[0].clone();
let seq = documentCopy.getIn(pathArray);

@@ -195,3 +203,3 @@ if (!seq) {

// Modification succeeded, replace document with modified copy
this.document = documentCopy;
this.documents[0] = documentCopy;
return this;

@@ -214,3 +222,3 @@ }

const pathArray = this.toPathArray(path);
const seq = this.document.getIn(pathArray);
const seq = this.documents[0].getIn(pathArray);
if (!seq) {

@@ -224,3 +232,3 @@ throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.seqDoesNotExist, { path }), errors_1.errorCode.seqDoesNotExist);

const newValue = mode === 'merge' ? merge_1.default(node.toJSON(), value) : value;
const newNode = this.document.createNode(newValue);
const newNode = this.documents[0].createNode(newValue);
seq.items.splice(seq.items.indexOf(node), 1, newNode);

@@ -242,3 +250,3 @@ return this;

const pathArray = this.toPathArray(path);
const seq = this.document.getIn(pathArray);
const seq = this.documents[0].getIn(pathArray);
if (!seq || !seq.items) {

@@ -274,3 +282,3 @@ throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.seqDoesNotExist, { path }), errors_1.errorCode.seqDoesNotExist);

const pathArray = this.toPathArray(path);
const node = start || this.document;
const node = start || this.documents[0];
const targetNode = node === null || node === void 0 ? void 0 : node.getIn(pathArray);

@@ -277,0 +285,0 @@ if (!targetNode) {

@@ -12,3 +12,3 @@ {

},
"version": "0.13.2",
"version": "0.13.3",
"main": "dist/index.js",

@@ -15,0 +15,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc