From 383285ecd5292bf9a825e05904955b937de84cc9 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 4 Jun 2022 08:51:01 +0200 Subject: Initial commit --- node_modules/yaml/browser/dist/nodes/Pair.js | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 node_modules/yaml/browser/dist/nodes/Pair.js (limited to 'node_modules/yaml/browser/dist/nodes/Pair.js') diff --git a/node_modules/yaml/browser/dist/nodes/Pair.js b/node_modules/yaml/browser/dist/nodes/Pair.js new file mode 100644 index 0000000..3fe0fa3 --- /dev/null +++ b/node_modules/yaml/browser/dist/nodes/Pair.js @@ -0,0 +1,36 @@ +import { createNode } from '../doc/createNode.js'; +import { stringifyPair } from '../stringify/stringifyPair.js'; +import { addPairToJSMap } from './addPairToJSMap.js'; +import { NODE_TYPE, PAIR, isNode } from './Node.js'; + +function createPair(key, value, ctx) { + const k = createNode(key, undefined, ctx); + const v = createNode(value, undefined, ctx); + return new Pair(k, v); +} +class Pair { + constructor(key, value = null) { + Object.defineProperty(this, NODE_TYPE, { value: PAIR }); + this.key = key; + this.value = value; + } + clone(schema) { + let { key, value } = this; + if (isNode(key)) + key = key.clone(schema); + if (isNode(value)) + value = value.clone(schema); + return new Pair(key, value); + } + toJSON(_, ctx) { + const pair = (ctx === null || ctx === void 0 ? void 0 : ctx.mapAsMap) ? new Map() : {}; + return addPairToJSMap(ctx, pair, this); + } + toString(ctx, onComment, onChompKeep) { + return (ctx === null || ctx === void 0 ? void 0 : ctx.doc) + ? stringifyPair(this, ctx, onComment, onChompKeep) + : JSON.stringify(this); + } +} + +export { Pair, createPair }; -- cgit