Socket
Socket
Sign inDemoInstall

yaml

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaml - npm Package Compare versions

Comparing version 1.9.2 to 1.10.0

browser/dist/legacy-exports.js

903

browser/dist/index.js

@@ -1,22 +0,7 @@

import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import { d as defaultTagPrefix, _ as _createForOfIteratorHelper, a as _typeof, b as _createClass, c as _classCallCheck, e as _defineProperty, Y as YAMLSyntaxError, T as Type, f as YAMLWarning, g as YAMLSemanticError, h as _slicedToArray, i as YAMLError, j as _inherits, k as _createSuper } from './PlainValue-ff5147c6.js';
import { parse as parse$1 } from './parse-cst.js';
import { b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions, N as Node, P as Pair, S as Scalar, c as stringifyString, A as Alias, Y as YAMLSeq, d as YAMLMap, M as Merge, C as Collection, r as resolveNode, e as isEmptyPath, t as toJSON, f as addComment } from './resolveSeq-04825f30.js';
import { S as Schema } from './Schema-2bf2c74e.js';
import { w as warn } from './warnings-0e4b70d3.js';
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
import { parse as parseCST } from './cst/parse';
import { Document as YAMLDocument } from './Document';
import { YAMLSemanticError } from './errors';
import { Schema } from './schema';
import { binaryOptions, boolOptions, intOptions, nullOptions, strOptions } from './tags/options';
import { warn } from './warnings';
var defaultOptions = {

@@ -79,3 +64,851 @@ anchorPrefix: 'a',

};
var documentOptions = {
'1.0': {
schema: 'yaml-1.1',
merge: true,
tagPrefixes: [{
handle: '!',
prefix: defaultTagPrefix
}, {
handle: '!!',
prefix: 'tag:private.yaml.org,2002:'
}]
},
'1.1': {
schema: 'yaml-1.1',
merge: true,
tagPrefixes: [{
handle: '!',
prefix: '!'
}, {
handle: '!!',
prefix: defaultTagPrefix
}]
},
'1.2': {
schema: 'core',
merge: false,
tagPrefixes: [{
handle: '!',
prefix: '!'
}, {
handle: '!!',
prefix: defaultTagPrefix
}]
}
};
function stringifyTag(doc, tag) {
if ((doc.version || doc.options.version) === '1.0') {
var priv = tag.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/);
if (priv) return '!' + priv[1];
var vocab = tag.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);
return vocab ? "!".concat(vocab[1], "/").concat(vocab[2]) : "!".concat(tag.replace(/^tag:/, ''));
}
var p = doc.tagPrefixes.find(function (p) {
return tag.indexOf(p.prefix) === 0;
});
if (!p) {
var dtp = doc.getDefaults().tagPrefixes;
p = dtp && dtp.find(function (p) {
return tag.indexOf(p.prefix) === 0;
});
}
if (!p) return tag[0] === '!' ? tag : "!<".concat(tag, ">");
var suffix = tag.substr(p.prefix.length).replace(/[!,[\]{}]/g, function (ch) {
return {
'!': '%21',
',': '%2C',
'[': '%5B',
']': '%5D',
'{': '%7B',
'}': '%7D'
}[ch];
});
return p.handle + suffix;
}
function getTagObject(tags, item) {
if (item instanceof Alias) return Alias;
if (item.tag) {
var match = tags.filter(function (t) {
return t.tag === item.tag;
});
if (match.length > 0) return match.find(function (t) {
return t.format === item.format;
}) || match[0];
}
var tagObj, obj;
if (item instanceof Scalar) {
obj = item.value; // TODO: deprecate/remove class check
var _match = tags.filter(function (t) {
return t.identify && t.identify(obj) || t.class && obj instanceof t.class;
});
tagObj = _match.find(function (t) {
return t.format === item.format;
}) || _match.find(function (t) {
return !t.format;
});
} else {
obj = item;
tagObj = tags.find(function (t) {
return t.nodeClass && obj instanceof t.nodeClass;
});
}
if (!tagObj) {
var name = obj && obj.constructor ? obj.constructor.name : _typeof(obj);
throw new Error("Tag not resolved for ".concat(name, " value"));
}
return tagObj;
} // needs to be called before value stringifier to allow for circular anchor refs
function stringifyProps(node, tagObj, _ref) {
var anchors = _ref.anchors,
doc = _ref.doc;
var props = [];
var anchor = doc.anchors.getName(node);
if (anchor) {
anchors[anchor] = node;
props.push("&".concat(anchor));
}
if (node.tag) {
props.push(stringifyTag(doc, node.tag));
} else if (!tagObj.default) {
props.push(stringifyTag(doc, tagObj.tag));
}
return props.join(' ');
}
function stringify(item, ctx, onComment, onChompKeep) {
var _ctx$doc = ctx.doc,
anchors = _ctx$doc.anchors,
schema = _ctx$doc.schema;
var tagObj;
if (!(item instanceof Node)) {
var createCtx = {
aliasNodes: [],
onTagObj: function onTagObj(o) {
return tagObj = o;
},
prevObjects: new Map()
};
item = schema.createNode(item, true, null, createCtx);
var _iterator = _createForOfIteratorHelper(createCtx.aliasNodes),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var alias = _step.value;
alias.source = alias.source.node;
var name = anchors.getName(alias.source);
if (!name) {
name = anchors.newName();
anchors.map[name] = alias.source;
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
if (item instanceof Pair) return item.toString(ctx, onComment, onChompKeep);
if (!tagObj) tagObj = getTagObject(schema.tags, item);
var props = stringifyProps(item, tagObj, ctx);
if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart || 0) + props.length + 1;
var str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof Scalar ? stringifyString(item, ctx, onComment, onChompKeep) : item.toString(ctx, onComment, onChompKeep);
if (!props) return str;
return item instanceof Scalar || str[0] === '{' || str[0] === '[' ? "".concat(props, " ").concat(str) : "".concat(props, "\n").concat(ctx.indent).concat(str);
}
var Anchors = /*#__PURE__*/function () {
_createClass(Anchors, null, [{
key: "validAnchorNode",
value: function validAnchorNode(node) {
return node instanceof Scalar || node instanceof YAMLSeq || node instanceof YAMLMap;
}
}]);
function Anchors(prefix) {
_classCallCheck(this, Anchors);
_defineProperty(this, "map", {});
this.prefix = prefix;
}
_createClass(Anchors, [{
key: "createAlias",
value: function createAlias(node, name) {
this.setAnchor(node, name);
return new Alias(node);
}
}, {
key: "createMergePair",
value: function createMergePair() {
var _this = this;
var merge = new Merge();
for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
sources[_key] = arguments[_key];
}
merge.value.items = sources.map(function (s) {
if (s instanceof Alias) {
if (s.source instanceof YAMLMap) return s;
} else if (s instanceof YAMLMap) {
return _this.createAlias(s);
}
throw new Error('Merge sources must be Map nodes or their Aliases');
});
return merge;
}
}, {
key: "getName",
value: function getName(node) {
var map = this.map;
return Object.keys(map).find(function (a) {
return map[a] === node;
});
}
}, {
key: "getNames",
value: function getNames() {
return Object.keys(this.map);
}
}, {
key: "getNode",
value: function getNode(name) {
return this.map[name];
}
}, {
key: "newName",
value: function newName(prefix) {
if (!prefix) prefix = this.prefix;
var names = Object.keys(this.map);
for (var i = 1; true; ++i) {
var name = "".concat(prefix).concat(i);
if (!names.includes(name)) return name;
}
} // During parsing, map & aliases contain CST nodes
}, {
key: "resolveNodes",
value: function resolveNodes() {
var map = this.map,
_cstAliases = this._cstAliases;
Object.keys(map).forEach(function (a) {
map[a] = map[a].resolved;
});
_cstAliases.forEach(function (a) {
a.source = a.source.resolved;
});
delete this._cstAliases;
}
}, {
key: "setAnchor",
value: function setAnchor(node, name) {
if (node != null && !Anchors.validAnchorNode(node)) {
throw new Error('Anchors may only be set for Scalar, Seq and Map nodes');
}
if (name && /[\x00-\x19\s,[\]{}]/.test(name)) {
throw new Error('Anchor names must not contain whitespace or control characters');
}
var map = this.map;
var prev = node && Object.keys(map).find(function (a) {
return map[a] === node;
});
if (prev) {
if (!name) {
return prev;
} else if (prev !== name) {
delete map[prev];
map[name] = node;
}
} else {
if (!name) {
if (!node) return null;
name = this.newName();
}
map[name] = node;
}
return name;
}
}]);
return Anchors;
}();
var visit = function visit(node, tags) {
if (node && _typeof(node) === 'object') {
var tag = node.tag;
if (node instanceof Collection) {
if (tag) tags[tag] = true;
node.items.forEach(function (n) {
return visit(n, tags);
});
} else if (node instanceof Pair) {
visit(node.key, tags);
visit(node.value, tags);
} else if (node instanceof Scalar) {
if (tag) tags[tag] = true;
}
}
return tags;
};
var listTagNames = function listTagNames(node) {
return Object.keys(visit(node, {}));
};
function parseContents(doc, contents) {
var comments = {
before: [],
after: []
};
var body = undefined;
var spaceBefore = false;
var _iterator = _createForOfIteratorHelper(contents),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var node = _step.value;
if (node.valueRange) {
if (body !== undefined) {
var msg = 'Document contains trailing content not separated by a ... or --- line';
doc.errors.push(new YAMLSyntaxError(node, msg));
break;
}
var res = resolveNode(doc, node);
if (spaceBefore) {
res.spaceBefore = true;
spaceBefore = false;
}
body = res;
} else if (node.comment !== null) {
var cc = body === undefined ? comments.before : comments.after;
cc.push(node.comment);
} else if (node.type === Type.BLANK_LINE) {
spaceBefore = true;
if (body === undefined && comments.before.length > 0 && !doc.commentBefore) {
// space-separated comments at start are parsed as document comments
doc.commentBefore = comments.before.join('\n');
comments.before = [];
}
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
doc.contents = body || null;
if (!body) {
doc.comment = comments.before.concat(comments.after).join('\n') || null;
} else {
var cb = comments.before.join('\n');
if (cb) {
var cbNode = body instanceof Collection && body.items[0] ? body.items[0] : body;
cbNode.commentBefore = cbNode.commentBefore ? "".concat(cb, "\n").concat(cbNode.commentBefore) : cb;
}
doc.comment = comments.after.join('\n') || null;
}
}
function resolveTagDirective(_ref, directive) {
var tagPrefixes = _ref.tagPrefixes;
var _directive$parameters = _slicedToArray(directive.parameters, 2),
handle = _directive$parameters[0],
prefix = _directive$parameters[1];
if (!handle || !prefix) {
var msg = 'Insufficient parameters given for %TAG directive';
throw new YAMLSemanticError(directive, msg);
}
if (tagPrefixes.some(function (p) {
return p.handle === handle;
})) {
var _msg = 'The %TAG directive must only be given at most once per handle in the same document.';
throw new YAMLSemanticError(directive, _msg);
}
return {
handle: handle,
prefix: prefix
};
}
function resolveYamlDirective(doc, directive) {
var _directive$parameters2 = _slicedToArray(directive.parameters, 1),
version = _directive$parameters2[0];
if (directive.name === 'YAML:1.0') version = '1.0';
if (!version) {
var msg = 'Insufficient parameters given for %YAML directive';
throw new YAMLSemanticError(directive, msg);
}
if (!documentOptions[version]) {
var v0 = doc.version || doc.options.version;
var _msg2 = "Document will be parsed as YAML ".concat(v0, " rather than YAML ").concat(version);
doc.warnings.push(new YAMLWarning(directive, _msg2));
}
return version;
}
function parseDirectives(doc, directives, prevDoc) {
var directiveComments = [];
var hasDirectives = false;
var _iterator = _createForOfIteratorHelper(directives),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var directive = _step.value;
var comment = directive.comment,
name = directive.name;
switch (name) {
case 'TAG':
try {
doc.tagPrefixes.push(resolveTagDirective(doc, directive));
} catch (error) {
doc.errors.push(error);
}
hasDirectives = true;
break;
case 'YAML':
case 'YAML:1.0':
if (doc.version) {
var msg = 'The %YAML directive must only be given at most once per document.';
doc.errors.push(new YAMLSemanticError(directive, msg));
}
try {
doc.version = resolveYamlDirective(doc, directive);
} catch (error) {
doc.errors.push(error);
}
hasDirectives = true;
break;
default:
if (name) {
var _msg3 = "YAML only supports %TAG and %YAML directives, and not %".concat(name);
doc.warnings.push(new YAMLWarning(directive, _msg3));
}
}
if (comment) directiveComments.push(comment);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (prevDoc && !hasDirectives && '1.1' === (doc.version || prevDoc.version || doc.options.version)) {
var copyTagPrefix = function copyTagPrefix(_ref2) {
var handle = _ref2.handle,
prefix = _ref2.prefix;
return {
handle: handle,
prefix: prefix
};
};
doc.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix);
doc.version = prevDoc.version;
}
doc.commentBefore = directiveComments.join('\n') || null;
}
function assertCollection(contents) {
if (contents instanceof Collection) return true;
throw new Error('Expected a YAML collection as document contents');
}
var Document = /*#__PURE__*/function () {
function Document(options) {
_classCallCheck(this, Document);
this.anchors = new Anchors(options.anchorPrefix);
this.commentBefore = null;
this.comment = null;
this.contents = null;
this.directivesEndMarker = null;
this.errors = [];
this.options = options;
this.schema = null;
this.tagPrefixes = [];
this.version = null;
this.warnings = [];
}
_createClass(Document, [{
key: "add",
value: function add(value) {
assertCollection(this.contents);
return this.contents.add(value);
}
}, {
key: "addIn",
value: function addIn(path, value) {
assertCollection(this.contents);
this.contents.addIn(path, value);
}
}, {
key: "delete",
value: function _delete(key) {
assertCollection(this.contents);
return this.contents.delete(key);
}
}, {
key: "deleteIn",
value: function deleteIn(path) {
if (isEmptyPath(path)) {
if (this.contents == null) return false;
this.contents = null;
return true;
}
assertCollection(this.contents);
return this.contents.deleteIn(path);
}
}, {
key: "getDefaults",
value: function getDefaults() {
return Document.defaults[this.version] || Document.defaults[this.options.version] || {};
}
}, {
key: "get",
value: function get(key, keepScalar) {
return this.contents instanceof Collection ? this.contents.get(key, keepScalar) : undefined;
}
}, {
key: "getIn",
value: function getIn(path, keepScalar) {
if (isEmptyPath(path)) return !keepScalar && this.contents instanceof Scalar ? this.contents.value : this.contents;
return this.contents instanceof Collection ? this.contents.getIn(path, keepScalar) : undefined;
}
}, {
key: "has",
value: function has(key) {
return this.contents instanceof Collection ? this.contents.has(key) : false;
}
}, {
key: "hasIn",
value: function hasIn(path) {
if (isEmptyPath(path)) return this.contents !== undefined;
return this.contents instanceof Collection ? this.contents.hasIn(path) : false;
}
}, {
key: "set",
value: function set(key, value) {
assertCollection(this.contents);
this.contents.set(key, value);
}
}, {
key: "setIn",
value: function setIn(path, value) {
if (isEmptyPath(path)) this.contents = value;else {
assertCollection(this.contents);
this.contents.setIn(path, value);
}
}
}, {
key: "setSchema",
value: function setSchema(id, customTags) {
if (!id && !customTags && this.schema) return;
if (typeof id === 'number') id = id.toFixed(1);
if (id === '1.0' || id === '1.1' || id === '1.2') {
if (this.version) this.version = id;else this.options.version = id;
delete this.options.schema;
} else if (id && typeof id === 'string') {
this.options.schema = id;
}
if (Array.isArray(customTags)) this.options.customTags = customTags;
var opt = Object.assign({}, this.getDefaults(), this.options);
this.schema = new Schema(opt);
}
}, {
key: "parse",
value: function parse(node, prevDoc) {
if (this.options.keepCstNodes) this.cstNode = node;
if (this.options.keepNodeTypes) this.type = 'DOCUMENT';
var _node$directives = node.directives,
directives = _node$directives === void 0 ? [] : _node$directives,
_node$contents = node.contents,
contents = _node$contents === void 0 ? [] : _node$contents,
directivesEndMarker = node.directivesEndMarker,
error = node.error,
valueRange = node.valueRange;
if (error) {
if (!error.source) error.source = this;
this.errors.push(error);
}
parseDirectives(this, directives, prevDoc);
if (directivesEndMarker) this.directivesEndMarker = true;
this.range = valueRange ? [valueRange.start, valueRange.end] : null;
this.setSchema();
this.anchors._cstAliases = [];
parseContents(this, contents);
this.anchors.resolveNodes();
if (this.options.prettyErrors) {
var _iterator = _createForOfIteratorHelper(this.errors),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _error = _step.value;
if (_error instanceof YAMLError) _error.makePretty();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var _iterator2 = _createForOfIteratorHelper(this.warnings),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var warn = _step2.value;
if (warn instanceof YAMLError) warn.makePretty();
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
}
return this;
}
}, {
key: "listNonDefaultTags",
value: function listNonDefaultTags() {
return listTagNames(this.contents).filter(function (t) {
return t.indexOf(Schema.defaultPrefix) !== 0;
});
}
}, {
key: "setTagPrefix",
value: function setTagPrefix(handle, prefix) {
if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !');
if (prefix) {
var prev = this.tagPrefixes.find(function (p) {
return p.handle === handle;
});
if (prev) prev.prefix = prefix;else this.tagPrefixes.push({
handle: handle,
prefix: prefix
});
} else {
this.tagPrefixes = this.tagPrefixes.filter(function (p) {
return p.handle !== handle;
});
}
}
}, {
key: "toJSON",
value: function toJSON$1(arg, onAnchor) {
var _this = this;
var _this$options = this.options,
keepBlobsInJSON = _this$options.keepBlobsInJSON,
mapAsMap = _this$options.mapAsMap,
maxAliasCount = _this$options.maxAliasCount;
var keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof Scalar));
var ctx = {
doc: this,
indentStep: ' ',
keep: keep,
mapAsMap: keep && !!mapAsMap,
maxAliasCount: maxAliasCount,
stringify: stringify // Requiring directly in Pair would create circular dependencies
};
var anchorNames = Object.keys(this.anchors.map);
if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(function (name) {
return [_this.anchors.map[name], {
alias: [],
aliasCount: 0,
count: 1
}];
}));
var res = toJSON(this.contents, arg, ctx);
if (typeof onAnchor === 'function' && ctx.anchors) {
var _iterator3 = _createForOfIteratorHelper(ctx.anchors.values()),
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var _step3$value = _step3.value,
count = _step3$value.count,
_res = _step3$value.res;
onAnchor(_res, count);
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
}
return res;
}
}, {
key: "toString",
value: function toString() {
if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified');
var indentSize = this.options.indent;
if (!Number.isInteger(indentSize) || indentSize <= 0) {
var s = JSON.stringify(indentSize);
throw new Error("\"indent\" option must be a positive integer, not ".concat(s));
}
this.setSchema();
var lines = [];
var hasDirectives = false;
if (this.version) {
var vd = '%YAML 1.2';
if (this.schema.name === 'yaml-1.1') {
if (this.version === '1.0') vd = '%YAML:1.0';else if (this.version === '1.1') vd = '%YAML 1.1';
}
lines.push(vd);
hasDirectives = true;
}
var tagNames = this.listNonDefaultTags();
this.tagPrefixes.forEach(function (_ref) {
var handle = _ref.handle,
prefix = _ref.prefix;
if (tagNames.some(function (t) {
return t.indexOf(prefix) === 0;
})) {
lines.push("%TAG ".concat(handle, " ").concat(prefix));
hasDirectives = true;
}
});
if (hasDirectives || this.directivesEndMarker) lines.push('---');
if (this.commentBefore) {
if (hasDirectives || !this.directivesEndMarker) lines.unshift('');
lines.unshift(this.commentBefore.replace(/^/gm, '#'));
}
var ctx = {
anchors: {},
doc: this,
indent: '',
indentStep: ' '.repeat(indentSize),
stringify: stringify // Requiring directly in nodes would create circular dependencies
};
var chompKeep = false;
var contentComment = null;
if (this.contents) {
if (this.contents instanceof Node) {
if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
ctx.forceBlockIndent = !!this.comment;
contentComment = this.contents.comment;
}
var onChompKeep = contentComment ? null : function () {
return chompKeep = true;
};
var body = stringify(this.contents, ctx, function () {
return contentComment = null;
}, onChompKeep);
lines.push(addComment(body, '', contentComment));
} else if (this.contents !== undefined) {
lines.push(stringify(this.contents, ctx));
}
if (this.comment) {
if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push('');
lines.push(this.comment.replace(/^/gm, '#'));
}
return lines.join('\n') + '\n';
}
}]);
return Document;
}();
_defineProperty(Document, "defaults", documentOptions);
function createNode(value) {

@@ -90,3 +923,3 @@ var wrapScalars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

var options = Object.assign({}, YAMLDocument.defaults[defaultOptions.version], defaultOptions);
var options = Object.assign({}, Document.defaults[defaultOptions.version], defaultOptions);
var schema = new Schema(options);

@@ -96,3 +929,3 @@ return schema.createNode(value, wrapScalars, tag);

var Document = /*#__PURE__*/function (_YAMLDocument) {
var Document$1 = /*#__PURE__*/function (_YAMLDocument) {
_inherits(Document, _YAMLDocument);

@@ -109,3 +942,3 @@

return Document;
}(YAMLDocument);
}(Document);

@@ -116,3 +949,3 @@ function parseAllDocuments(src, options) {

var _iterator = _createForOfIteratorHelper(parseCST(src)),
var _iterator = _createForOfIteratorHelper(parse$1(src)),
_step;

@@ -123,3 +956,3 @@

var cstDoc = _step.value;
var doc = new Document(options);
var doc = new Document$1(options);
doc.parse(cstDoc, prev);

@@ -139,4 +972,4 @@ stream.push(doc);

function parseDocument(src, options) {
var cst = parseCST(src);
var doc = new Document(options).parse(cst[0]);
var cst = parse$1(src);
var doc = new Document$1(options).parse(cst[0]);

@@ -160,4 +993,4 @@ if (cst.length > 1) {

function stringify(value, options) {
var doc = new Document(options);
function stringify$1(value, options) {
var doc = new Document$1(options);
doc.contents = value;

@@ -167,12 +1000,14 @@ return String(doc);

export var YAML = {
var YAML = {
createNode: createNode,
defaultOptions: defaultOptions,
Document: Document,
Document: Document$1,
parse: parse,
parseAllDocuments: parseAllDocuments,
parseCST: parseCST,
parseCST: parse$1,
parseDocument: parseDocument,
scalarOptions: scalarOptions,
stringify: stringify
};
stringify: stringify$1
};
export { YAML };

2

browser/index.js

@@ -1,1 +0,1 @@

export { YAML as default } from './dist'
module.exports = require('./dist').YAML

@@ -1,4 +0,2 @@

export { YAMLMap as default } from './dist/schema/Map'
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
module.exports = require('./dist/types').YAMLMap
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,4 +0,2 @@

export { Pair as default } from './dist/schema/Pair'
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
module.exports = require('./dist/types').Pair
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,1 +0,1 @@

export { parse as default } from './dist/cst/parse'
module.exports = require('./dist/parse-cst').parse

@@ -1,4 +0,2 @@

export { Scalar as default } from './dist/schema/Scalar'
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
module.exports = require('./dist/types').Scalar
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,12 +0,9 @@

import { Schema } from './dist/schema'
import { nullOptions, strOptions } from './dist/tags/options'
import { stringifyString } from './dist/stringify'
const types = require('./dist/types')
const util = require('./dist/util')
Schema.nullOptions = nullOptions
Schema.strOptions = strOptions
Schema.stringify = stringifyString
export { Schema as default }
export { nullOptions, strOptions, stringifyString as stringify }
module.exports = types.Schema
module.exports.nullOptions = types.nullOptions
module.exports.strOptions = types.strOptions
module.exports.stringify = util.stringifyString
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,4 +0,2 @@

export { YAMLSeq as default } from './dist/schema/Seq'
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
module.exports = require('./dist/types').YAMLSeq
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,13 +0,1 @@

export {
binaryOptions,
boolOptions,
intOptions,
nullOptions,
strOptions
} from './dist/tags/options'
export { Schema } from './dist/schema'
export { YAMLMap } from './dist/schema/Map'
export { YAMLSeq } from './dist/schema/Seq'
export { Pair } from './dist/schema/Pair'
export { Scalar } from './dist/schema/Scalar'
export * from './dist/types.js'

@@ -1,6 +0,8 @@

import { binary } from '../dist/tags/yaml-1.1/binary'
export { binary }
export default [binary]
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
exports.binary = legacy.binary
exports.default = [exports.binary]
legacy.warnFileDeprecation(__filename)

@@ -1,4 +0,3 @@

export { omap as default } from '../dist/tags/yaml-1.1/omap'
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
module.exports = legacy.omap
legacy.warnFileDeprecation(__filename)

@@ -1,4 +0,3 @@

export { pairs as default } from '../dist/tags/yaml-1.1/pairs'
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
module.exports = legacy.pairs
legacy.warnFileDeprecation(__filename)

@@ -1,4 +0,3 @@

export { set as default } from '../dist/tags/yaml-1.1/set'
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
module.exports = legacy.set
legacy.warnFileDeprecation(__filename)

@@ -1,6 +0,10 @@

import { floatTime, intTime, timestamp } from '../dist/tags/yaml-1.1/timestamp'
export { floatTime, intTime, timestamp }
export default [intTime, floatTime, timestamp]
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
import { warnFileDeprecation } from './dist/warnings'
warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
exports.default = [legacy.intTime, legacy.floatTime, legacy.timestamp]
exports.floatTime = legacy.floatTime
exports.intTime = legacy.intTime
exports.timestamp = legacy.timestamp
legacy.warnFileDeprecation(__filename)

@@ -1,18 +0,1 @@

export { findPair } from './dist/schema/Map'
export { parseMap } from './dist/schema/parseMap'
export { parseSeq } from './dist/schema/parseSeq'
export {
stringifyNumber,
stringifyString,
toJSON,
Type
} from './dist/stringify'
export {
YAMLError,
YAMLReferenceError,
YAMLSemanticError,
YAMLSyntaxError,
YAMLWarning
} from './dist/errors'
export * from './dist/util.js'

@@ -1,75 +0,10 @@

"use strict";
'use strict';
exports.YAML = void 0;
var PlainValue = require('./PlainValue-ec8e588e.js');
var parseCst = require('./parse-cst.js');
require('./resolveSeq-4a68b39b.js');
var Document$1 = require('./Document-2cf6b08c.js');
var Schema = require('./Schema-42e9705c.js');
var warnings = require('./warnings-39684f17.js');
var _parse = require("./cst/parse");
var _Document = require("./Document");
var _errors = require("./errors");
var _schema = require("./schema");
var _options = require("./tags/options");
var _warnings = require("./warnings");
const defaultOptions = {
anchorPrefix: 'a',
customTags: null,
indent: 2,
indentSeq: true,
keepCstNodes: false,
keepNodeTypes: true,
keepBlobsInJSON: true,
mapAsMap: false,
maxAliasCount: 100,
prettyErrors: false,
// TODO Set true in v2
simpleKeys: false,
version: '1.2'
};
const scalarOptions = {
get binary() {
return _options.binaryOptions;
},
set binary(opt) {
Object.assign(_options.binaryOptions, opt);
},
get bool() {
return _options.boolOptions;
},
set bool(opt) {
Object.assign(_options.boolOptions, opt);
},
get int() {
return _options.intOptions;
},
set int(opt) {
Object.assign(_options.intOptions, opt);
},
get null() {
return _options.nullOptions;
},
set null(opt) {
Object.assign(_options.nullOptions, opt);
},
get str() {
return _options.strOptions;
},
set str(opt) {
Object.assign(_options.strOptions, opt);
}
};
function createNode(value, wrapScalars = true, tag) {

@@ -81,10 +16,10 @@ if (tag === undefined && typeof wrapScalars === 'string') {

const options = Object.assign({}, _Document.Document.defaults[defaultOptions.version], defaultOptions);
const schema = new _schema.Schema(options);
const options = Object.assign({}, Document$1.Document.defaults[Document$1.defaultOptions.version], Document$1.defaultOptions);
const schema = new Schema.Schema(options);
return schema.createNode(value, wrapScalars, tag);
}
class Document extends _Document.Document {
class Document extends Document$1.Document {
constructor(options) {
super(Object.assign({}, defaultOptions, options));
super(Object.assign({}, Document$1.defaultOptions, options));
}

@@ -98,3 +33,3 @@

for (const cstDoc of (0, _parse.parse)(src)) {
for (const cstDoc of parseCst.parse(src)) {
const doc = new Document(options);

@@ -110,3 +45,3 @@ doc.parse(cstDoc, prev);

function parseDocument(src, options) {
const cst = (0, _parse.parse)(src);
const cst = parseCst.parse(src);
const doc = new Document(options).parse(cst[0]);

@@ -116,3 +51,3 @@

const errMsg = 'Source contains multiple documents; please use YAML.parseAllDocuments()';
doc.errors.unshift(new _errors.YAMLSemanticError(cst[1], errMsg));
doc.errors.unshift(new PlainValue.YAMLSemanticError(cst[1], errMsg));
}

@@ -125,3 +60,3 @@

const doc = parseDocument(src, options);
doc.warnings.forEach(warning => (0, _warnings.warn)(warning));
doc.warnings.forEach(warning => warnings.warn(warning));
if (doc.errors.length > 0) throw doc.errors[0];

@@ -139,11 +74,12 @@ return doc.toJSON();

createNode,
defaultOptions,
defaultOptions: Document$1.defaultOptions,
Document,
parse,
parseAllDocuments,
parseCST: _parse.parse,
parseCST: parseCst.parse,
parseDocument,
scalarOptions,
scalarOptions: Document$1.scalarOptions,
stringify
};
exports.YAML = YAML;
exports.YAML = YAML;

@@ -1,10 +0,10 @@

"use strict";
'use strict';
exports.testEvents = testEvents;
require('./PlainValue-ec8e588e.js');
var parseCst = require('./parse-cst.js');
require('./resolveSeq-4a68b39b.js');
var Document$1 = require('./Document-2cf6b08c.js');
require('./Schema-42e9705c.js');
require('./warnings-39684f17.js');
var _parse = require("./cst/parse");
var _Document = require("./Document");
// test harness for yaml-test-suite event tests
function testEvents(src, options) {

@@ -16,3 +16,3 @@ const opt = Object.assign({

}, options);
const docs = (0, _parse.parse)(src).map(cstDoc => new _Document.Document(opt).parse(cstDoc));
const docs = parseCst.parse(src).map(cstDoc => new Document$1.Document(opt).parse(cstDoc));
const errDoc = docs.find(doc => doc.errors.length > 0);

@@ -161,2 +161,4 @@ const error = errDoc ? errDoc.errors[0].message : null;

}
}
}
exports.testEvents = testEvents;
import { CST } from './parse-cst'
import { AST, Scalar, Schema, YAMLMap, YAMLSeq } from './types'
import {
AST,
Alias,
Collection,
Merge,
Node,
Scalar,
Schema,
YAMLMap,
YAMLSeq
} from './types'
import { Type, YAMLError, YAMLWarning } from './util'

@@ -186,6 +196,7 @@

export class Document extends AST.Collection {
export class Document extends Collection {
cstNode?: CST.Document
constructor(options?: Options)
tag: never
directivesEndMarker?: boolean
type: Type.DOCUMENT

@@ -198,3 +209,3 @@ /**

/** The document contents. */
contents: AST.AstNode | null
contents: any
/** Errors encountered during parsing. */

@@ -254,2 +265,3 @@ errors: YAMLError[]

interface Parsed extends Document {
contents: Node | null
/** The schema used with the document. */

@@ -264,3 +276,3 @@ schema: Schema

*/
createAlias(node: AST.Node, name?: string): AST.Alias
createAlias(node: Node, name?: string): Alias
/**

@@ -270,7 +282,9 @@ * Create a new `Merge` node with the given source nodes.

*/
createMergePair(...nodes: AST.Node[]): AST.Merge
createMergePair(...nodes: Node[]): Merge
/** The anchor name associated with `node`, if set. */
getName(node: AST.Node): undefined | string
getName(node: Node): undefined | string
/** List of all defined anchor names. */
getNames(): string[]
/** The node associated with the anchor `name`, if set. */
getNode(name: string): undefined | AST.Node
getNode(name: string): undefined | Node
/**

@@ -285,3 +299,3 @@ * Find an available anchor name with the given `prefix` and a

*/
setAnchor(node: AST.Node | null, name?: string): void | string
setAnchor(node: Node | null, name?: string): void | string
}

@@ -288,0 +302,0 @@

@@ -1,2 +0,2 @@

module.exports = require('./dist/schema/Map').YAMLMap
require('./dist/warnings').warnFileDeprecation(__filename)
module.exports = require('./dist/types').YAMLMap
require('./dist/legacy-exports').warnFileDeprecation(__filename)
{
"name": "yaml",
"version": "1.9.2",
"version": "1.10.0",
"license": "ISC",

@@ -21,3 +21,3 @@ "author": "Eemeli Aro <eemeli@gmail.com>",

"*.mjs",
"!.*.js"
"!*config.js"
],

@@ -46,7 +46,5 @@ "type": "commonjs",

".": "./index.js",
"./": "./",
"./parse-cst": "./parse-cst.js",
"./types": [
{
"default": "./types.js",
"import": "./types.mjs"

@@ -58,18 +56,18 @@ },

{
"default": "./util.js",
"import": "./util.mjs"
},
"./util.js"
]
],
"./": "./"
},
"scripts": {
"browser:build": "cross-env BABEL_ENV=browser babel src/ --out-dir browser/dist/",
"build": "npm run build:node && npm run build:browser",
"build:browser": "rollup -c rollup.browser-config.js",
"build:node": "rollup -c rollup.node-config.js",
"clean": "git clean -fdxe node_modules",
"dist:build": "babel src/ --out-dir dist/",
"build": "npm run dist:build && npm run browser:build",
"lint": "eslint src/",
"prettier": "prettier --write .",
"lint": "eslint src/",
"start": "npm run dist:build && node -i -e 'YAML=require(\".\")'",
"test": "cross-env TRACE_LEVEL=log jest",
"test:trace": "cross-env TRACE_LEVEL=trace,log jest --no-cache",
"start": "cross-env TRACE_LEVEL=log npm run build:node && node -i -e 'YAML=require(\".\")'",
"test": "jest",
"test:dist": "npm run build:node && jest",
"test:types": "tsc --lib ES2017 --noEmit tests/typings.ts",

@@ -83,14 +81,2 @@ "docs:install": "cd docs-slate && bundle install",

"browserslist": "> 0.5%, not dead",
"jest": {
"collectCoverageFrom": [
"src/**/*.js"
],
"testMatch": [
"**/tests/**/*.js"
],
"testPathIgnorePatterns": [
"tests/common",
"tests/cst/common"
]
},
"prettier": {

@@ -103,23 +89,20 @@ "arrowParens": "avoid",

"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-env": "^7.9.6",
"@rollup/plugin-babel": "^5.0.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^25.3.0",
"babel-jest": "^26.0.1",
"babel-plugin-trace": "^1.1.0",
"common-tags": "^1.8.0",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint": "^7.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"fast-check": "^1.24.1",
"jest": "^25.3.0",
"prettier": "^2.0.4",
"typescript": "^3.8.3"
"fast-check": "^1.24.2",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"rollup": "^2.10.2",
"typescript": "^3.9.2"
},
"dependencies": {
"@babel/runtime": "^7.9.2"
},
"engines": {

@@ -126,0 +109,0 @@ "node": ">= 6"

@@ -1,2 +0,2 @@

module.exports = require('./dist/schema/Pair').Pair
require('./dist/warnings').warnFileDeprecation(__filename)
module.exports = require('./dist/types').Pair
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,1 +0,1 @@

module.exports = require('./dist/cst/parse').parse
module.exports = require('./dist/parse-cst').parse

@@ -5,12 +5,12 @@ # YAML <a href="https://www.npmjs.com/package/yaml"><img align="right" src="https://badge.fury.io/js/yaml.svg" title="npm package" /></a><a href="https://travis-ci.org/eemeli/yaml"><img align="right" src="https://travis-ci.org/eemeli/yaml.svg?branch=master" title="Build status" /></a>

The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/). It runs on Node.js 6 and later with no external dependencies, and in browsers from IE 11 upwards (Note: `@babel/runtime` is used only by the `"browser"` entry point).
The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/). It has no external dependencies and runs on Node.js 6 and later, and in browsers from IE 11 upwards.
For the purposes of versioning, any changes that break any of the endpoints or APIs documented here will be considered semver-major breaking changes. Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed).
For more information, see the project's documentation site: [**eemeli.org/yaml**](https://eemeli.org/yaml/)
> To install:
To install:
```sh
npm install yaml
# or
yarn add yaml
```

@@ -17,0 +17,0 @@

@@ -1,2 +0,2 @@

module.exports = require('./dist/schema/Scalar').Scalar
require('./dist/warnings').warnFileDeprecation(__filename)
module.exports = require('./dist/types').Scalar
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,7 +0,9 @@

module.exports = require('./dist/schema').Schema
const opt = require('./dist/tags/options')
module.exports.nullOptions = opt.nullOptions
module.exports.strOptions = opt.strOptions
module.exports.stringify = require('./dist/stringify').stringifyString
const types = require('./dist/types')
const util = require('./dist/util')
require('./dist/warnings').warnFileDeprecation(__filename)
module.exports = types.Schema
module.exports.nullOptions = types.nullOptions
module.exports.strOptions = types.strOptions
module.exports.stringify = util.stringifyString
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -1,2 +0,2 @@

module.exports = require('./dist/schema/Seq').YAMLSeq
require('./dist/warnings').warnFileDeprecation(__filename)
module.exports = require('./dist/types').YAMLSeq
require('./dist/legacy-exports').warnFileDeprecation(__filename)

@@ -25,3 +25,3 @@ import { Document, scalarOptions } from './index'

* Convert any value into a `Node` using this schema, recursively turning
* objects into collectsions.
* objects into collections.
*

@@ -39,3 +39,10 @@ * @param wrapScalars If `true`, also wraps plain values in `Scalar` objects;

ctx?: Schema.CreateNodeContext
): AST.Node
): Node
/**
* Convert a key and a value into a `Pair` using this schema, recursively
* wrapping all values as `Scalar` or `Collection` nodes.
*
* @param ctx To not wrap scalars, use a context `{ wrapScalars: false }`
*/
createPair(key: any, value: any, ctx?: Schema.CreateNodeContext): Pair
merge: boolean

@@ -152,3 +159,3 @@ name: Schema.Name

stringify?: (
item: AST.Node,
item: Node,
ctx: Schema.StringifyContext,

@@ -176,3 +183,3 @@ onComment?: () => void,

*/
resolve(doc: Document, cstNode: CST.Node): AST.Node | any
resolve(doc: Document, cstNode: CST.Node): Node | any
}

@@ -190,3 +197,3 @@

*/
resolve(...match: string[]): AST.Node | any
resolve(...match: string[]): Node | any
/**

@@ -202,5 +209,26 @@ * Together with `default` allows for values to be stringified without an

export class Scalar extends AST.Node {
export class Node {
/** A comment on or immediately after this */
comment?: string | null
/** A comment before this */
commentBefore?: string | null
/** Only available when `keepCstNodes` is set to `true` */
cstNode?: CST.Node
/**
* The [start, end] range of characters of the source parsed
* into this node (undefined for pairs or if not parsed)
*/
range?: [number, number] | null
/** A blank line before this node and its commentBefore */
spaceBefore?: boolean
/** A fully qualified tag, if required */
tag?: string
/** A plain JS representation of this node */
toJSON(arg?: any): any
/** The type of this node */
type?: Type | Pair.Type
}
export class Scalar extends Node {
constructor(value: any)
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any
type?: Scalar.Type

@@ -213,2 +241,4 @@ /**

value: any
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any
toString(): string
}

@@ -224,5 +254,11 @@ export namespace Scalar {

export class Pair extends AST.Node {
export class Alias extends Node {
type: Type.ALIAS
source: Node
cstNode?: CST.Alias
toString(ctx: Schema.StringifyContext): string
}
export class Pair extends Node {
constructor(key: any, value?: any)
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
type: Pair.Type.PAIR | Pair.Type.MERGE_PAIR

@@ -234,2 +270,8 @@ /** Always Node or null when parsed, but can be set to anything. */

cstNode?: never // no corresponding cstNode
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
toString(
ctx?: Schema.StringifyContext,
onComment?: () => void,
onChompKeep?: () => void
): string
}

@@ -243,10 +285,62 @@ export namespace Pair {

export class YAMLMap extends AST.Collection {
export class Merge extends Pair {
type: Pair.Type.MERGE_PAIR
/** Always Scalar('<<'), defined by the type specification */
key: AST.PlainValue
/** Always YAMLSeq<Alias(Map)>, stringified as *A if length = 1 */
value: YAMLSeq
toString(ctx?: Schema.StringifyContext, onComment?: () => void): string
}
export class Collection extends Node {
type?: Type.MAP | Type.FLOW_MAP | Type.SEQ | Type.FLOW_SEQ | Type.DOCUMENT
items: any[]
schema?: Schema
/**
* Adds a value to the collection. For `!!map` and `!!omap` the value must
* be a Pair instance or a `{ key, value }` object, which may not have a key
* that already exists in the map.
*/
add(value: any): void
addIn(path: Iterable<any>, value: any): void
/**
* Removes a value from the collection.
* @returns `true` if the item was found and removed.
*/
delete(key: any): boolean
deleteIn(path: Iterable<any>): boolean
/**
* Returns item at `key`, or `undefined` if not found. By default unwraps
* scalar values from their surrounding node; to disable set `keepScalar` to
* `true` (collections are always returned intact).
*/
get(key: any, keepScalar?: boolean): any
getIn(path: Iterable<any>, keepScalar?: boolean): any
/**
* Checks if the collection includes a value with the key `key`.
*/
has(key: any): boolean
hasIn(path: Iterable<any>): boolean
/**
* Sets a value in this collection. For `!!set`, `value` needs to be a
* boolean to add/remove the item from the set.
*/
set(key: any, value: any): void
setIn(path: Iterable<any>, value: any): void
}
export class YAMLMap extends Collection {
type?: Type.FLOW_MAP | Type.MAP
items: Array<Pair | AST.Merge>
items: Array<Pair>
hasAllNullValues(): boolean
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
toString(
ctx?: Schema.StringifyContext,
onComment?: () => void,
onChompKeep?: () => void
): string
}
export class YAMLSeq extends AST.Collection {
export class YAMLSeq extends Collection {
type?: Type.FLOW_SEQ | Type.SEQ

@@ -259,76 +353,10 @@ delete(key: number | string | Scalar): boolean

toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any[]
toString(
ctx?: Schema.StringifyContext,
onComment?: () => void,
onChompKeep?: () => void
): string
}
export namespace AST {
type AstNode = ScalarNode | CollectionNode | Alias
type ScalarNode =
| BlockFolded
| BlockLiteral
| PlainValue
| QuoteDouble
| QuoteSingle
type CollectionNode = FlowMap | BlockMap | FlowSeq | BlockSeq
class Node {
/** A comment on or immediately after this */
comment?: string | null
/** A comment before this */
commentBefore?: string | null
/** Only available when `keepCstNodes` is set to `true` */
cstNode?: CST.Node
/**
* The [start, end] range of characters of the source parsed
* into this node (undefined for pairs or if not parsed)
*/
range?: [number, number] | null
/** A blank line before this node and its commentBefore */
spaceBefore?: boolean
/** A fully qualified tag, if required */
tag?: string
/** A plain JS representation of this node */
toJSON(arg?: any): any
/** The type of this node */
type?: Type | Pair.Type
}
class Collection extends Node {
type?: Type.MAP | Type.FLOW_MAP | Type.SEQ | Type.FLOW_SEQ | Type.DOCUMENT
items: any[]
schema?: Schema
/**
* Adds a value to the collection. For `!!map` and `!!omap` the value must
* be a Pair instance or a `{ key, value }` object, which may not have a key
* that already exists in the map.
*/
add(value: any): void
addIn(path: Iterable<any>, value: any): void
/**
* Removes a value from the collection.
* @returns `true` if the item was found and removed.
*/
delete(key: any): boolean
deleteIn(path: Iterable<any>): boolean
/**
* Returns item at `key`, or `undefined` if not found. By default unwraps
* scalar values from their surrounding node; to disable set `keepScalar` to
* `true` (collections are always returned intact).
*/
get(key: any, keepScalar?: boolean): any
getIn(path: Iterable<any>, keepScalar?: boolean): any
/**
* Checks if the collection includes a value with the key `key`.
*/
has(key: any): boolean
hasIn(path: Iterable<any>): boolean
/**
* Sets a value in this collection. For `!!set`, `value` needs to be a
* boolean to add/remove the item from the set.
*/
set(key: any, value: any): void
setIn(path: Iterable<any>, value: any): void
}
interface NodeToJsonContext {

@@ -369,16 +397,2 @@ anchors?: any[]

interface Alias extends Node {
type: Type.ALIAS
source: AstNode
cstNode?: CST.Alias
}
interface Merge extends Pair {
type: Pair.Type.MERGE_PAIR
/** Always Scalar('<<'), defined by the type specification */
key: PlainValue
/** Always YAMLSeq<Alias(Map)>, stringified as *A if length = 1 */
value: YAMLSeq
}
interface FlowMap extends YAMLMap {

@@ -396,3 +410,3 @@ type: Type.FLOW_MAP

type: Type.FLOW_SEQ
items: Array<AstNode | Pair>
items: Array<Node>
cstNode?: CST.FlowSeq

@@ -403,5 +417,5 @@ }

type: Type.SEQ
items: Array<AstNode | null>
items: Array<Node | null>
cstNode?: CST.Seq
}
}

@@ -1,12 +0,17 @@

const opt = require('./dist/tags/options')
exports.binaryOptions = opt.binaryOptions
exports.boolOptions = opt.boolOptions
exports.intOptions = opt.intOptions
exports.nullOptions = opt.nullOptions
exports.strOptions = opt.strOptions
const types = require('./dist/types')
exports.Schema = require('./dist/schema').Schema
exports.YAMLMap = require('./dist/schema/Map').YAMLMap
exports.YAMLSeq = require('./dist/schema/Seq').YAMLSeq
exports.Pair = require('./dist/schema/Pair').Pair
exports.Scalar = require('./dist/schema/Scalar').Scalar
exports.binaryOptions = types.binaryOptions
exports.boolOptions = types.boolOptions
exports.intOptions = types.intOptions
exports.nullOptions = types.nullOptions
exports.strOptions = types.strOptions
exports.Schema = types.Schema
exports.Alias = types.Alias
exports.Collection = types.Collection
exports.Merge = types.Merge
exports.Node = types.Node
exports.Pair = types.Pair
exports.Scalar = types.Scalar
exports.YAMLMap = types.YAMLMap
exports.YAMLSeq = types.YAMLSeq
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
exports.binary = require('../dist/tags/yaml-1.1/binary').binary
const legacy = require('../dist/legacy-exports')
exports.binary = legacy.binary
exports.default = [exports.binary]
require('../dist/warnings').warnFileDeprecation(__filename)
legacy.warnFileDeprecation(__filename)

@@ -1,2 +0,3 @@

module.exports = require('../dist/tags/yaml-1.1/omap').omap
require('../dist/warnings').warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
module.exports = legacy.omap
legacy.warnFileDeprecation(__filename)

@@ -1,2 +0,3 @@

module.exports = require('../dist/tags/yaml-1.1/pairs').pairs
require('../dist/warnings').warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
module.exports = legacy.pairs
legacy.warnFileDeprecation(__filename)

@@ -1,2 +0,3 @@

module.exports = require('../dist/tags/yaml-1.1/set').set
require('../dist/warnings').warnFileDeprecation(__filename)
const legacy = require('../dist/legacy-exports')
module.exports = legacy.set
legacy.warnFileDeprecation(__filename)
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
const ts = require('../dist/tags/yaml-1.1/timestamp')
exports.default = [ts.intTime, ts.floatTime, ts.timestamp]
exports.floatTime = ts.floatTime
exports.intTime = ts.intTime
exports.timestamp = ts.timestamp
const legacy = require('../dist/legacy-exports')
exports.default = [legacy.intTime, legacy.floatTime, legacy.timestamp]
exports.floatTime = legacy.floatTime
exports.intTime = legacy.intTime
exports.timestamp = legacy.timestamp
require('../dist/warnings').warnFileDeprecation(__filename)
legacy.warnFileDeprecation(__filename)

@@ -1,16 +0,16 @@

exports.findPair = require('./dist/schema/Map').findPair
exports.parseMap = require('./dist/schema/parseMap').parseMap
exports.parseSeq = require('./dist/schema/parseSeq').parseSeq
const util = require('./dist/util')
const str = require('./dist/stringify')
exports.stringifyNumber = str.stringifyNumber
exports.stringifyString = str.stringifyString
exports.toJSON = require('./dist/toJSON').toJSON
exports.Type = require('./dist/constants').Type
exports.findPair = util.findPair
exports.toJSON = util.toJSON
exports.parseMap = util.parseMap
exports.parseSeq = util.parseSeq
const err = require('./dist/errors')
exports.YAMLError = err.YAMLError
exports.YAMLReferenceError = err.YAMLReferenceError
exports.YAMLSemanticError = err.YAMLSemanticError
exports.YAMLSyntaxError = err.YAMLSyntaxError
exports.YAMLWarning = err.YAMLWarning
exports.stringifyNumber = util.stringifyNumber
exports.stringifyString = util.stringifyString
exports.Type = util.Type
exports.YAMLError = util.YAMLError
exports.YAMLReferenceError = util.YAMLReferenceError
exports.YAMLSemanticError = util.YAMLSemanticError
exports.YAMLSyntaxError = util.YAMLSyntaxError
exports.YAMLWarning = util.YAMLWarning

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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