diff --git a/package-lock.json b/package-lock.json index b2660bb0b0..eabf953c3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,6 +57,7 @@ "jquery": "3.7.1", "js-ascon": "^1.3.0", "js-sha3": "^0.12.0", + "js-yaml": "^5.2.3", "jsesc": "^3.1.0", "json5": "^2.2.3", "jsonata": "^2.2.2", @@ -2813,6 +2814,29 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@eslint/eslintrc/node_modules/js-yaml": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz", + "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@eslint/js": { "version": "9.39.5", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.5.tgz", @@ -7363,6 +7387,29 @@ "node": ">=6" } }, + "node_modules/cosmiconfig/node_modules/js-yaml": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz", + "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/crc-32": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", @@ -12489,10 +12536,9 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz", - "integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==", - "dev": true, + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.2.3.tgz", + "integrity": "sha512-n+mUVyUX5bVv7G/G2zyIHOhdxfuU1dY2NOFzTQUWiMUbFss8b57NFlgCCaggU78wSw5KVS9cllzeLyzyR+n5nw==", "funding": [ { "type": "github", @@ -12508,7 +12554,7 @@ "argparse": "^2.0.1" }, "bin": { - "js-yaml": "bin/js-yaml.js" + "js-yaml": "bin/js-yaml.mjs" } }, "node_modules/jsdoc-type-pratt-parser": { @@ -13622,6 +13668,29 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/mocha/node_modules/js-yaml": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz", + "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/mocha/node_modules/minimatch": { "version": "5.1.9", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", diff --git a/package.json b/package.json index c8e4c491a9..8cd81c9e4b 100644 --- a/package.json +++ b/package.json @@ -142,6 +142,7 @@ "jquery": "3.7.1", "js-ascon": "^1.3.0", "js-sha3": "^0.12.0", + "js-yaml": "^5.2.3", "jsesc": "^3.1.0", "json5": "^2.2.3", "jsonata": "^2.2.2", diff --git a/src/core/operations/JSONtoYAML.mjs b/src/core/operations/JSONtoYAML.mjs index 0d4cc626bc..39d7a94928 100644 --- a/src/core/operations/JSONtoYAML.mjs +++ b/src/core/operations/JSONtoYAML.mjs @@ -6,7 +6,7 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import YAML from "yaml"; +import { dump } from "js-yaml"; /** * JSON to YAML operation @@ -35,9 +35,9 @@ class JSONtoYAML extends Operation { */ run(input, args) { try { - return YAML.stringify(input); + return dump(input); } catch (err) { - throw new OperationError("Test"); + throw new OperationError("Unable to stringify YAML: " + err); } } diff --git a/src/core/operations/YAMLToJSON.mjs b/src/core/operations/YAMLToJSON.mjs index 5b98657523..c2e201f0e4 100644 --- a/src/core/operations/YAMLToJSON.mjs +++ b/src/core/operations/YAMLToJSON.mjs @@ -6,7 +6,8 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import jsYaml from "js-yaml"; +import { load } from "js-yaml"; + /** * YAML to JSON operation */ @@ -34,7 +35,7 @@ class YAMLToJSON extends Operation { */ run(input, args) { try { - return jsYaml.load(input); + return load(input); } catch (err) { throw new OperationError("Unable to parse YAML: " + err); }