yaml 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/dist/Document.js +28 -8
- package/browser/dist/cst/Alias.js +1 -1
- package/browser/dist/cst/BlankLine.js +1 -1
- package/browser/dist/cst/BlockValue.js +1 -1
- package/browser/dist/cst/Collection.js +1 -1
- package/browser/dist/cst/CollectionItem.js +1 -1
- package/browser/dist/cst/Comment.js +1 -1
- package/browser/dist/cst/Directive.js +1 -1
- package/browser/dist/cst/Document.js +1 -1
- package/browser/dist/cst/FlowCollection.js +1 -1
- package/browser/dist/cst/PlainValue.js +1 -1
- package/browser/dist/cst/QuoteDouble.js +1 -1
- package/browser/dist/cst/QuoteSingle.js +1 -1
- package/browser/dist/errors.js +1 -1
- package/browser/dist/index.js +1 -1
- package/browser/dist/schema/Alias.js +3 -9
- package/browser/dist/schema/Collection.js +1 -1
- package/browser/dist/schema/Map.js +1 -1
- package/browser/dist/schema/Merge.js +1 -1
- package/browser/dist/schema/Pair.js +1 -1
- package/browser/dist/schema/Scalar.js +1 -1
- package/browser/dist/schema/Seq.js +1 -1
- package/browser/dist/tags/yaml-1.1/omap.js +1 -1
- package/browser/dist/tags/yaml-1.1/set.js +1 -1
- package/browser/dist/toJSON.js +1 -3
- package/dist/Document.js +10 -6
- package/dist/schema/Alias.js +2 -2
- package/dist/toJSON.js +1 -1
- package/index.d.ts +10 -2
- package/package.json +9 -9
package/browser/dist/Document.js
CHANGED
|
@@ -655,7 +655,7 @@ export var Document = /*#__PURE__*/function () {
|
|
|
655
655
|
}
|
|
656
656
|
}, {
|
|
657
657
|
key: "toJSON",
|
|
658
|
-
value: function toJSON(arg) {
|
|
658
|
+
value: function toJSON(arg, onAnchor) {
|
|
659
659
|
var _this3 = this;
|
|
660
660
|
|
|
661
661
|
var _this$options = this.options,
|
|
@@ -671,15 +671,35 @@ export var Document = /*#__PURE__*/function () {
|
|
|
671
671
|
maxAliasCount: maxAliasCount
|
|
672
672
|
};
|
|
673
673
|
var anchorNames = Object.keys(this.anchors.map);
|
|
674
|
-
if (anchorNames.length > 0) ctx.anchors = anchorNames.map(function (name) {
|
|
675
|
-
return {
|
|
674
|
+
if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(function (name) {
|
|
675
|
+
return [_this3.anchors.map[name], {
|
|
676
676
|
alias: [],
|
|
677
677
|
aliasCount: 0,
|
|
678
|
-
count: 1
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
678
|
+
count: 1
|
|
679
|
+
}];
|
|
680
|
+
}));
|
|
681
|
+
|
|
682
|
+
var res = _toJSON(this.contents, arg, ctx);
|
|
683
|
+
|
|
684
|
+
if (typeof onAnchor === 'function' && ctx.anchors) {
|
|
685
|
+
var _iterator4 = _createForOfIteratorHelper(ctx.anchors.values()),
|
|
686
|
+
_step4;
|
|
687
|
+
|
|
688
|
+
try {
|
|
689
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
690
|
+
var _step4$value = _step4.value,
|
|
691
|
+
count = _step4$value.count,
|
|
692
|
+
_res = _step4$value.res;
|
|
693
|
+
onAnchor(_res, count);
|
|
694
|
+
}
|
|
695
|
+
} catch (err) {
|
|
696
|
+
_iterator4.e(err);
|
|
697
|
+
} finally {
|
|
698
|
+
_iterator4.f();
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
return res;
|
|
683
703
|
}
|
|
684
704
|
}, {
|
|
685
705
|
key: "toString",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _get from "@babel/runtime/helpers/get";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _get from "@babel/runtime/helpers/get";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _get from "@babel/runtime/helpers/get";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
|
9
9
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _get from "@babel/runtime/helpers/get";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _get from "@babel/runtime/helpers/get";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
|
9
9
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
package/browser/dist/errors.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
package/browser/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
2
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
3
4
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
5
|
|
|
6
6
|
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; } } }; }
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
|
@@ -24,9 +24,7 @@ import { Pair } from './Pair';
|
|
|
24
24
|
|
|
25
25
|
var getAliasCount = function getAliasCount(node, anchors) {
|
|
26
26
|
if (node instanceof Alias) {
|
|
27
|
-
var anchor = anchors.
|
|
28
|
-
return a.node === node.source;
|
|
29
|
-
});
|
|
27
|
+
var anchor = anchors.get(node.source);
|
|
30
28
|
return anchor.count * anchor.aliasCount;
|
|
31
29
|
} else if (node instanceof Collection) {
|
|
32
30
|
var count = 0;
|
|
@@ -94,14 +92,10 @@ export var Alias = /*#__PURE__*/function (_Node) {
|
|
|
94
92
|
_createClass(Alias, [{
|
|
95
93
|
key: "toJSON",
|
|
96
94
|
value: function toJSON(arg, ctx) {
|
|
97
|
-
var _this2 = this;
|
|
98
|
-
|
|
99
95
|
if (!ctx) return _toJSON(this.source, arg, ctx);
|
|
100
96
|
var anchors = ctx.anchors,
|
|
101
97
|
maxAliasCount = ctx.maxAliasCount;
|
|
102
|
-
var anchor = anchors.
|
|
103
|
-
return a.node === _this2.source;
|
|
104
|
-
});
|
|
98
|
+
var anchor = anchors.get(this.source);
|
|
105
99
|
/* istanbul ignore if */
|
|
106
100
|
|
|
107
101
|
if (!anchor || anchor.res === undefined) {
|
|
@@ -2,9 +2,9 @@ import _toArray from "@babel/runtime/helpers/toArray";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _get from "@babel/runtime/helpers/get";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
|
|
8
8
|
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); }; }
|
|
9
9
|
|
|
@@ -2,9 +2,9 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _get from "@babel/runtime/helpers/get";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
8
|
|
|
9
9
|
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; } } }; }
|
|
10
10
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
7
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
|
|
7
7
|
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); }; }
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _get from "@babel/runtime/helpers/get";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
|
|
8
8
|
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; } } }; }
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
|
|
9
9
|
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; } } }; }
|
|
@@ -2,9 +2,9 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _get from "@babel/runtime/helpers/get";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
|
|
10
10
|
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; } } }; }
|
package/browser/dist/toJSON.js
CHANGED
|
@@ -4,9 +4,7 @@ export function toJSON(value, arg, ctx) {
|
|
|
4
4
|
});
|
|
5
5
|
|
|
6
6
|
if (value && typeof value.toJSON === 'function') {
|
|
7
|
-
var anchor = ctx && ctx.anchors && ctx.anchors.
|
|
8
|
-
return a.node === value;
|
|
9
|
-
});
|
|
7
|
+
var anchor = ctx && ctx.anchors && ctx.anchors.get(value);
|
|
10
8
|
if (anchor) ctx.onCreate = function (res) {
|
|
11
9
|
anchor.res = res;
|
|
12
10
|
delete ctx.onCreate;
|
package/dist/Document.js
CHANGED
|
@@ -571,7 +571,7 @@ class Document {
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
|
|
574
|
-
toJSON(arg) {
|
|
574
|
+
toJSON(arg, onAnchor) {
|
|
575
575
|
const {
|
|
576
576
|
keepBlobsInJSON,
|
|
577
577
|
mapAsMap,
|
|
@@ -586,13 +586,17 @@ class Document {
|
|
|
586
586
|
maxAliasCount
|
|
587
587
|
};
|
|
588
588
|
const anchorNames = Object.keys(this.anchors.map);
|
|
589
|
-
if (anchorNames.length > 0) ctx.anchors = anchorNames.map(name =>
|
|
589
|
+
if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(name => [this.anchors.map[name], {
|
|
590
590
|
alias: [],
|
|
591
591
|
aliasCount: 0,
|
|
592
|
-
count: 1
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
592
|
+
count: 1
|
|
593
|
+
}]));
|
|
594
|
+
const res = (0, _toJSON.toJSON)(this.contents, arg, ctx);
|
|
595
|
+
if (typeof onAnchor === 'function' && ctx.anchors) for (const {
|
|
596
|
+
count,
|
|
597
|
+
res
|
|
598
|
+
} of ctx.anchors.values()) onAnchor(res, count);
|
|
599
|
+
return res;
|
|
596
600
|
}
|
|
597
601
|
|
|
598
602
|
toString() {
|
package/dist/schema/Alias.js
CHANGED
|
@@ -18,7 +18,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
18
18
|
|
|
19
19
|
const getAliasCount = (node, anchors) => {
|
|
20
20
|
if (node instanceof Alias) {
|
|
21
|
-
const anchor = anchors.
|
|
21
|
+
const anchor = anchors.get(node.source);
|
|
22
22
|
return anchor.count * anchor.aliasCount;
|
|
23
23
|
} else if (node instanceof _Collection.Collection) {
|
|
24
24
|
let count = 0;
|
|
@@ -71,7 +71,7 @@ class Alias extends _Node.Node {
|
|
|
71
71
|
anchors,
|
|
72
72
|
maxAliasCount
|
|
73
73
|
} = ctx;
|
|
74
|
-
const anchor = anchors.
|
|
74
|
+
const anchor = anchors.get(this.source);
|
|
75
75
|
/* istanbul ignore if */
|
|
76
76
|
|
|
77
77
|
if (!anchor || anchor.res === undefined) {
|
package/dist/toJSON.js
CHANGED
|
@@ -6,7 +6,7 @@ function toJSON(value, arg, ctx) {
|
|
|
6
6
|
if (Array.isArray(value)) return value.map((v, i) => toJSON(v, String(i), ctx));
|
|
7
7
|
|
|
8
8
|
if (value && typeof value.toJSON === 'function') {
|
|
9
|
-
const anchor = ctx && ctx.anchors && ctx.anchors.
|
|
9
|
+
const anchor = ctx && ctx.anchors && ctx.anchors.get(value);
|
|
10
10
|
if (anchor) ctx.onCreate = res => {
|
|
11
11
|
anchor.res = res;
|
|
12
12
|
delete ctx.onCreate;
|
package/index.d.ts
CHANGED
|
@@ -233,8 +233,16 @@ export class Document extends AST.Collection {
|
|
|
233
233
|
): void
|
|
234
234
|
/** Set `handle` as a shorthand string for the `prefix` tag namespace. */
|
|
235
235
|
setTagPrefix(handle: string, prefix: string): void
|
|
236
|
-
/**
|
|
237
|
-
|
|
236
|
+
/**
|
|
237
|
+
* A plain JavaScript representation of the document `contents`.
|
|
238
|
+
*
|
|
239
|
+
* @param arg Used by `JSON.stringify` to indicate the array index or property
|
|
240
|
+
* name. If its value is a `string` and the document `contents` has a scalar
|
|
241
|
+
* value, the `keepBlobsInJSON` option has no effect.
|
|
242
|
+
* @param onAnchor If defined, called with the resolved `value` and reference
|
|
243
|
+
* `count` for each anchor in the document.
|
|
244
|
+
* */
|
|
245
|
+
toJSON(arg?: string, onAnchor?: (value: any, count: number) => void): any
|
|
238
246
|
/** A YAML representation of the document. */
|
|
239
247
|
toString(): string
|
|
240
248
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"repository": "github:eemeli/yaml",
|
|
@@ -99,21 +99,21 @@
|
|
|
99
99
|
"@babel/core": "^7.9.0",
|
|
100
100
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
|
101
101
|
"@babel/plugin-transform-runtime": "^7.9.0",
|
|
102
|
-
"@babel/preset-env": "^7.9.
|
|
102
|
+
"@babel/preset-env": "^7.9.5",
|
|
103
103
|
"babel-eslint": "^10.1.0",
|
|
104
|
-
"babel-jest": "^25.
|
|
104
|
+
"babel-jest": "^25.3.0",
|
|
105
105
|
"babel-plugin-trace": "^1.1.0",
|
|
106
106
|
"common-tags": "^1.8.0",
|
|
107
107
|
"cross-env": "^7.0.2",
|
|
108
108
|
"eslint": "^6.8.0",
|
|
109
|
-
"eslint-config-prettier": "^6.10.
|
|
110
|
-
"eslint-plugin-prettier": "^3.1.
|
|
111
|
-
"fast-check": "^1.
|
|
112
|
-
"jest": "^25.
|
|
113
|
-
"prettier": "^2.0.
|
|
109
|
+
"eslint-config-prettier": "^6.10.1",
|
|
110
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
111
|
+
"fast-check": "^1.24.1",
|
|
112
|
+
"jest": "^25.3.0",
|
|
113
|
+
"prettier": "^2.0.4"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@babel/runtime": "^7.9.
|
|
116
|
+
"@babel/runtime": "^7.9.2"
|
|
117
117
|
},
|
|
118
118
|
"engines": {
|
|
119
119
|
"node": ">= 6"
|