@swagger-api/apidom-ast 0.92.0 → 0.94.0

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.
Files changed (111) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/cjs/Error.cjs +12 -13
  3. package/cjs/Literal.cjs +10 -11
  4. package/cjs/Node.cjs +26 -32
  5. package/cjs/ParseResult.cjs +5 -12
  6. package/cjs/Position.cjs +25 -32
  7. package/cjs/index.cjs +9 -1
  8. package/cjs/json/nodes/JsonArray.cjs +5 -11
  9. package/cjs/json/nodes/JsonDocument.cjs +5 -12
  10. package/cjs/json/nodes/JsonEscapeSequence.cjs +3 -6
  11. package/cjs/json/nodes/JsonFalse.cjs +3 -6
  12. package/cjs/json/nodes/JsonKey.cjs +3 -6
  13. package/cjs/json/nodes/JsonNode.cjs +1 -2
  14. package/cjs/json/nodes/JsonNull.cjs +3 -6
  15. package/cjs/json/nodes/JsonNumber.cjs +3 -6
  16. package/cjs/json/nodes/JsonObject.cjs +5 -11
  17. package/cjs/json/nodes/JsonProperty.cjs +8 -17
  18. package/cjs/json/nodes/JsonString.cjs +8 -16
  19. package/cjs/json/nodes/JsonStringContent.cjs +3 -6
  20. package/cjs/json/nodes/JsonTrue.cjs +3 -6
  21. package/cjs/json/nodes/JsonValue.cjs +11 -12
  22. package/cjs/json/nodes/predicates.cjs +24 -12
  23. package/cjs/predicates.cjs +9 -5
  24. package/cjs/yaml/anchors-aliases/ReferenceManager.cjs +28 -0
  25. package/cjs/yaml/errors/YamlError.cjs +7 -0
  26. package/cjs/yaml/errors/YamlReferenceError.cjs +8 -0
  27. package/cjs/yaml/errors/YamlSchemaError.cjs +3 -2
  28. package/cjs/yaml/errors/YamlTagError.cjs +6 -0
  29. package/cjs/yaml/nodes/YamlAlias.cjs +11 -12
  30. package/cjs/yaml/nodes/YamlAnchor.cjs +11 -12
  31. package/cjs/yaml/nodes/YamlCollection.cjs +1 -2
  32. package/cjs/yaml/nodes/YamlComment.cjs +11 -12
  33. package/cjs/yaml/nodes/YamlDirective.cjs +16 -17
  34. package/cjs/yaml/nodes/YamlDocument.cjs +3 -6
  35. package/cjs/yaml/nodes/YamlKeyValuePair.cjs +29 -27
  36. package/cjs/yaml/nodes/YamlMapping.cjs +7 -13
  37. package/cjs/yaml/nodes/YamlNode.cjs +16 -15
  38. package/cjs/yaml/nodes/YamlScalar.cjs +11 -12
  39. package/cjs/yaml/nodes/YamlSequence.cjs +10 -16
  40. package/cjs/yaml/nodes/YamlStream.cjs +7 -15
  41. package/cjs/yaml/nodes/YamlStyle.cjs +2 -11
  42. package/cjs/yaml/nodes/YamlTag.cjs +12 -13
  43. package/cjs/yaml/nodes/predicates.cjs +23 -11
  44. package/cjs/yaml/schemas/ScalarTag.cjs +23 -32
  45. package/cjs/yaml/schemas/Tag.cjs +16 -7
  46. package/cjs/yaml/schemas/failsafe/GenericMapping.cjs +7 -19
  47. package/cjs/yaml/schemas/failsafe/GenericSequence.cjs +7 -19
  48. package/cjs/yaml/schemas/failsafe/GenericString.cjs +3 -16
  49. package/cjs/yaml/schemas/failsafe/index.cjs +83 -87
  50. package/cjs/yaml/schemas/json/Boolean.cjs +13 -21
  51. package/cjs/yaml/schemas/json/FloatingPoint.cjs +13 -21
  52. package/cjs/yaml/schemas/json/Integer.cjs +13 -21
  53. package/cjs/yaml/schemas/json/Null.cjs +12 -20
  54. package/cjs/yaml/schemas/json/index.cjs +20 -26
  55. package/dist/apidom-ast.browser.js +1672 -1889
  56. package/dist/apidom-ast.browser.min.js +1 -1
  57. package/es/Error.mjs +12 -13
  58. package/es/Literal.mjs +10 -11
  59. package/es/Node.mjs +26 -31
  60. package/es/ParseResult.mjs +5 -12
  61. package/es/Position.mjs +24 -31
  62. package/es/index.mjs +4 -1
  63. package/es/json/nodes/JsonArray.mjs +5 -11
  64. package/es/json/nodes/JsonDocument.mjs +5 -12
  65. package/es/json/nodes/JsonEscapeSequence.mjs +3 -6
  66. package/es/json/nodes/JsonFalse.mjs +3 -6
  67. package/es/json/nodes/JsonKey.mjs +3 -6
  68. package/es/json/nodes/JsonNode.mjs +1 -2
  69. package/es/json/nodes/JsonNull.mjs +3 -6
  70. package/es/json/nodes/JsonNumber.mjs +3 -6
  71. package/es/json/nodes/JsonObject.mjs +5 -11
  72. package/es/json/nodes/JsonProperty.mjs +8 -17
  73. package/es/json/nodes/JsonString.mjs +8 -16
  74. package/es/json/nodes/JsonStringContent.mjs +3 -6
  75. package/es/json/nodes/JsonTrue.mjs +3 -6
  76. package/es/json/nodes/JsonValue.mjs +11 -12
  77. package/es/json/nodes/predicates.mjs +12 -12
  78. package/es/predicates.mjs +5 -5
  79. package/es/yaml/anchors-aliases/ReferenceManager.mjs +24 -0
  80. package/es/yaml/errors/YamlError.mjs +3 -0
  81. package/es/yaml/errors/YamlReferenceError.mjs +3 -0
  82. package/es/yaml/errors/YamlSchemaError.mjs +2 -2
  83. package/es/yaml/errors/YamlTagError.mjs +6 -0
  84. package/es/yaml/nodes/YamlAlias.mjs +11 -12
  85. package/es/yaml/nodes/YamlAnchor.mjs +11 -12
  86. package/es/yaml/nodes/YamlCollection.mjs +1 -2
  87. package/es/yaml/nodes/YamlComment.mjs +11 -12
  88. package/es/yaml/nodes/YamlDirective.mjs +16 -17
  89. package/es/yaml/nodes/YamlDocument.mjs +3 -6
  90. package/es/yaml/nodes/YamlKeyValuePair.mjs +29 -27
  91. package/es/yaml/nodes/YamlMapping.mjs +7 -13
  92. package/es/yaml/nodes/YamlNode.mjs +16 -15
  93. package/es/yaml/nodes/YamlScalar.mjs +11 -12
  94. package/es/yaml/nodes/YamlSequence.mjs +10 -16
  95. package/es/yaml/nodes/YamlStream.mjs +7 -15
  96. package/es/yaml/nodes/YamlStyle.mjs +1 -9
  97. package/es/yaml/nodes/YamlTag.mjs +12 -13
  98. package/es/yaml/nodes/predicates.mjs +11 -10
  99. package/es/yaml/schemas/ScalarTag.mjs +23 -31
  100. package/es/yaml/schemas/Tag.mjs +17 -6
  101. package/es/yaml/schemas/failsafe/GenericMapping.mjs +8 -19
  102. package/es/yaml/schemas/failsafe/GenericSequence.mjs +8 -19
  103. package/es/yaml/schemas/failsafe/GenericString.mjs +3 -16
  104. package/es/yaml/schemas/failsafe/index.mjs +86 -90
  105. package/es/yaml/schemas/json/Boolean.mjs +14 -21
  106. package/es/yaml/schemas/json/FloatingPoint.mjs +14 -21
  107. package/es/yaml/schemas/json/Integer.mjs +14 -21
  108. package/es/yaml/schemas/json/Null.mjs +13 -20
  109. package/es/yaml/schemas/json/index.mjs +24 -30
  110. package/package.json +3 -4
  111. package/types/dist.d.ts +236 -158
@@ -1,16 +1,9 @@
1
- import stampit from 'stampit';
2
1
  import { head } from 'ramda';
3
2
  import JsonNode from "./JsonNode.mjs";
4
- const JsonDocument = stampit(JsonNode, {
5
- statics: {
6
- type: 'document'
7
- },
8
- methods: {
9
- // @ts-ignore
10
- get child() {
11
- // @ts-ignore
12
- return head(this.children);
13
- }
3
+ class JsonDocument extends JsonNode {
4
+ static type = 'document';
5
+ get child() {
6
+ return head(this.children);
14
7
  }
15
- });
8
+ }
16
9
  export default JsonDocument;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import JsonValue from "./JsonValue.mjs";
3
- const JsonEscapeSequence = stampit(JsonValue, {
4
- statics: {
5
- type: 'escapeSequence'
6
- }
7
- });
2
+ class JsonEscapeSequence extends JsonValue {
3
+ static type = 'escapeSequence';
4
+ }
8
5
  export default JsonEscapeSequence;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import JsonValue from "./JsonValue.mjs";
3
- const JsonFalse = stampit(JsonValue, {
4
- statics: {
5
- type: 'false'
6
- }
7
- });
2
+ class JsonFalse extends JsonValue {
3
+ static type = 'false';
4
+ }
8
5
  export default JsonFalse;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import JsonString from "./JsonString.mjs";
3
- const JsonKey = stampit(JsonString, {
4
- statics: {
5
- type: 'key'
6
- }
7
- });
2
+ class JsonKey extends JsonString {
3
+ static type = 'key';
4
+ }
8
5
  export default JsonKey;
@@ -1,4 +1,3 @@
1
- import stampit from 'stampit';
2
1
  import Node from "../../Node.mjs";
3
- const JsonNode = stampit(Node);
2
+ class JsonNode extends Node {}
4
3
  export default JsonNode;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import JsonValue from "./JsonValue.mjs";
3
- const JsonNull = stampit(JsonValue, {
4
- statics: {
5
- type: 'null'
6
- }
7
- });
2
+ class JsonNull extends JsonValue {
3
+ static type = 'null';
4
+ }
8
5
  export default JsonNull;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import JsonValue from "./JsonValue.mjs";
3
- const JsonNumber = stampit(JsonValue, {
4
- statics: {
5
- type: 'number'
6
- }
7
- });
2
+ class JsonNumber extends JsonValue {
3
+ static type = 'number';
4
+ }
8
5
  export default JsonNumber;
@@ -1,15 +1,9 @@
1
- import stampit from 'stampit';
2
1
  import JsonNode from "./JsonNode.mjs";
3
2
  import { isProperty } from "./predicates.mjs";
4
- const JsonObject = stampit(JsonNode, {
5
- statics: {
6
- type: 'object'
7
- },
8
- methods: {
9
- get properties() {
10
- // @ts-ignore
11
- return this.children.filter(isProperty);
12
- }
3
+ class JsonObject extends JsonNode {
4
+ static type = 'object';
5
+ get properties() {
6
+ return this.children.filter(isProperty);
13
7
  }
14
- });
8
+ }
15
9
  export default JsonObject;
@@ -1,21 +1,12 @@
1
- import stampit from 'stampit';
2
1
  import JsonNode from "./JsonNode.mjs";
3
2
  import { isArray, isFalse, isKey, isNull, isNumber, isObject, isString, isTrue } from "./predicates.mjs";
4
- const JsonProperty = stampit(JsonNode, {
5
- statics: {
6
- type: 'property'
7
- },
8
- methods: {
9
- // @ts-ignore
10
- get key() {
11
- // @ts-ignore
12
- return this.children.find(isKey);
13
- },
14
- // @ts-ignore
15
- get value() {
16
- // @ts-ignore
17
- return this.children.find(node => isFalse(node) || isTrue(node) || isNull(node) || isNumber(node) || isString(node) || isArray(node) || isObject(node));
18
- }
3
+ class JsonProperty extends JsonNode {
4
+ static type = 'property';
5
+ get key() {
6
+ return this.children.find(isKey);
19
7
  }
20
- });
8
+ get value() {
9
+ return this.children.find(node => isFalse(node) || isTrue(node) || isNull(node) || isNumber(node) || isString(node) || isArray(node) || isObject(node));
10
+ }
11
+ }
21
12
  export default JsonProperty;
@@ -1,21 +1,13 @@
1
- import stampit from 'stampit';
2
1
  import JsonNode from "./JsonNode.mjs";
3
2
  import { isEscapeSequence, isStringContent } from "./predicates.mjs";
4
- const JsonString = stampit(JsonNode, {
5
- statics: {
6
- type: 'string'
7
- },
8
- methods: {
9
- get value() {
10
- // @ts-ignore
11
- if (this.children.length === 1) {
12
- // @ts-ignore
13
- return this.children[0].value;
14
- }
15
- return this.children
16
- // @ts-ignore
17
- .filter(node => isStringContent(node) || isEscapeSequence(node)).reduce((acc, cur) => acc + cur.value, '');
3
+ class JsonString extends JsonNode {
4
+ static type = 'string';
5
+ get value() {
6
+ if (this.children.length === 1) {
7
+ const onlyChild = this.children[0];
8
+ return onlyChild.value;
18
9
  }
10
+ return this.children.filter(node => isStringContent(node) || isEscapeSequence(node)).reduce((acc, cur) => acc + cur.value, '');
19
11
  }
20
- });
12
+ }
21
13
  export default JsonString;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import JsonValue from "./JsonValue.mjs";
3
- const JsonStringContent = stampit(JsonValue, {
4
- statics: {
5
- type: 'stringContent'
6
- }
7
- });
2
+ class JsonStringContent extends JsonValue {
3
+ static type = 'stringContent';
4
+ }
8
5
  export default JsonStringContent;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import JsonValue from "./JsonValue.mjs";
3
- const JsonTrue = stampit(JsonValue, {
4
- statics: {
5
- type: 'true'
6
- }
7
- });
2
+ class JsonTrue extends JsonValue {
3
+ static type = 'true';
4
+ }
8
5
  export default JsonTrue;
@@ -1,16 +1,15 @@
1
- import stampit from 'stampit';
2
1
  import JsonNode from "./JsonNode.mjs";
3
- const JsonValue = stampit(JsonNode, {
4
- statics: {
5
- type: 'value'
6
- },
7
- props: {
8
- value: null
9
- },
10
- init({
11
- value = null
12
- } = {}) {
2
+ class JsonValue extends JsonNode {
3
+ static type = 'value';
4
+ value;
5
+ constructor({
6
+ value,
7
+ ...rest
8
+ }) {
9
+ super({
10
+ ...rest
11
+ });
13
12
  this.value = value;
14
13
  }
15
- });
14
+ }
16
15
  export default JsonValue;
@@ -1,13 +1,13 @@
1
1
  import { isNodeType } from "../../predicates.mjs";
2
- export const isDocument = isNodeType.bind(undefined, 'document');
3
- export const isString = isNodeType.bind(undefined, 'string');
4
- export const isFalse = isNodeType.bind(undefined, 'false');
5
- export const isTrue = isNodeType.bind(undefined, 'true');
6
- export const isNull = isNodeType.bind(undefined, 'null');
7
- export const isNumber = isNodeType.bind(undefined, 'number');
8
- export const isArray = isNodeType.bind(undefined, 'array');
9
- export const isObject = isNodeType.bind(undefined, 'object');
10
- export const isStringContent = isNodeType.bind(undefined, 'stringContent');
11
- export const isEscapeSequence = isNodeType.bind(undefined, 'escapeSequence');
12
- export const isProperty = isNodeType.bind(undefined, 'property');
13
- export const isKey = isNodeType.bind(undefined, 'key');
2
+ export const isDocument = node => isNodeType('document', node);
3
+ export const isString = node => isNodeType('string', node);
4
+ export const isFalse = node => isNodeType('false', node);
5
+ export const isTrue = node => isNodeType('true', node);
6
+ export const isNull = node => isNodeType('null', node);
7
+ export const isNumber = node => isNodeType('number', node);
8
+ export const isArray = node => isNodeType('array', node);
9
+ export const isObject = node => isNodeType('object', node);
10
+ export const isStringContent = node => isNodeType('stringContent', node);
11
+ export const isEscapeSequence = node => isNodeType('escapeSequence', node);
12
+ export const isProperty = node => isNodeType('property', node);
13
+ export const isKey = node => isNodeType('key', node);
package/es/predicates.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export const isNodeType = (type, node) => (node === null || node === void 0 ? void 0 : node.type) === type;
2
- export const isLiteral = isNodeType.bind(undefined, 'literal');
3
- export const isPosition = isNodeType.bind(undefined, 'position');
4
- export const isPoint = isNodeType.bind(undefined, 'point');
5
- export const isParseResult = isNodeType.bind(undefined, 'parseResult');
1
+ export const isNodeType = (type, node) => node != null && typeof node === 'object' && 'type' in node && node.type === type;
2
+ export const isLiteral = node => isNodeType('literal', node);
3
+ export const isPosition = node => isNodeType('position', node);
4
+ export const isPoint = node => isNodeType('point', node);
5
+ export const isParseResult = node => isNodeType('parseResult', node);
@@ -0,0 +1,24 @@
1
+ import YamlScalar from "../nodes/YamlScalar.mjs";
2
+ import YamlReferenceError from "../errors/YamlReferenceError.mjs";
3
+ import { isAnchor } from "../nodes/predicates.mjs";
4
+ import { YamlStyle, YamlStyleGroup } from "../nodes/YamlStyle.mjs";
5
+ /* eslint-disable class-methods-use-this */
6
+ class ReferenceManager {
7
+ addAnchor(node) {
8
+ if (!isAnchor(node.anchor)) {
9
+ throw new YamlReferenceError('Expected YAML anchor to be attached the the YAML AST node.', {
10
+ node
11
+ });
12
+ }
13
+ }
14
+ resolveAlias(alias) {
15
+ return new YamlScalar({
16
+ content: alias.content,
17
+ style: YamlStyle.Plain,
18
+ styleGroup: YamlStyleGroup.Flow
19
+ });
20
+ }
21
+ }
22
+ /* eslint-enable class-methods-use-this */
23
+
24
+ export default ReferenceManager;
@@ -0,0 +1,3 @@
1
+ import { ApiDOMStructuredError } from '@swagger-api/apidom-error';
2
+ class YamlError extends ApiDOMStructuredError {}
3
+ export default YamlError;
@@ -0,0 +1,3 @@
1
+ import YamlError from "./YamlError.mjs";
2
+ class YamlReferenceError extends YamlError {}
3
+ export default YamlReferenceError;
@@ -1,3 +1,3 @@
1
- import { ApiDOMStructuredError } from '@swagger-api/apidom-error';
2
- class YamlSchemaError extends ApiDOMStructuredError {}
1
+ import YamlError from "./YamlError.mjs";
2
+ class YamlSchemaError extends YamlError {}
3
3
  export default YamlSchemaError;
@@ -1,5 +1,11 @@
1
1
  import YamlSchemaError from "./YamlSchemaError.mjs";
2
2
  class YamlTagError extends YamlSchemaError {
3
+ specificTagName;
4
+ explicitTagName;
5
+ tagKind;
6
+ tagPosition;
7
+ nodeCanonicalContent;
8
+ node;
3
9
  constructor(message, structuredOptions) {
4
10
  super(message, structuredOptions);
5
11
  if (typeof structuredOptions !== 'undefined') {
@@ -1,16 +1,15 @@
1
- import stampit from 'stampit';
2
1
  import Node from "../../Node.mjs";
3
- const YamlAlias = stampit(Node, {
4
- statics: {
5
- type: 'alias'
6
- },
7
- props: {
8
- content: null
9
- },
10
- init({
11
- content = null
12
- } = {}) {
2
+ class YamlAlias extends Node {
3
+ static type = 'alias';
4
+ content;
5
+ constructor({
6
+ content,
7
+ ...rest
8
+ }) {
9
+ super({
10
+ ...rest
11
+ });
13
12
  this.content = content;
14
13
  }
15
- });
14
+ }
16
15
  export default YamlAlias;
@@ -1,16 +1,15 @@
1
- import stampit from 'stampit';
2
1
  import Node from "../../Node.mjs";
3
- const YamlAnchor = stampit(Node, {
4
- statics: {
5
- type: 'anchor'
6
- },
7
- props: {
8
- name: null
9
- },
10
- init({
11
- name = null
12
- } = {}) {
2
+ class YamlAnchor extends Node {
3
+ static type = 'anchor';
4
+ name;
5
+ constructor({
6
+ name,
7
+ ...rest
8
+ }) {
9
+ super({
10
+ ...rest
11
+ });
13
12
  this.name = name;
14
13
  }
15
- });
14
+ }
16
15
  export default YamlAnchor;
@@ -1,4 +1,3 @@
1
- import stampit from 'stampit';
2
1
  import YamlNode from "./YamlNode.mjs";
3
- const YamlCollection = stampit(YamlNode, {});
2
+ class YamlCollection extends YamlNode {}
4
3
  export default YamlCollection;
@@ -1,16 +1,15 @@
1
- import stampit from 'stampit';
2
1
  import Node from "../../Node.mjs";
3
- const YamlComment = stampit(Node, {
4
- statics: {
5
- type: 'comment'
6
- },
7
- props: {
8
- content: null
9
- },
10
- init({
11
- content = null
12
- } = {}) {
2
+ class YamlComment extends Node {
3
+ static type = 'comment';
4
+ content;
5
+ constructor({
6
+ content,
7
+ ...rest
8
+ }) {
9
+ super({
10
+ ...rest
11
+ });
13
12
  this.content = content;
14
13
  }
15
- });
14
+ }
16
15
  export default YamlComment;
@@ -1,24 +1,23 @@
1
- import stampit from 'stampit';
2
1
  import { mergeRight } from 'ramda';
3
2
  import Node from "../../Node.mjs";
4
- const YamlDirective = stampit(Node, {
5
- statics: {
6
- type: 'directive'
7
- },
8
- props: {
9
- name: null,
10
- parameters: null
11
- },
12
- init({
13
- name = null,
14
- parameters = {}
15
- } = {}) {
3
+ class YamlDirective extends Node {
4
+ static type = 'directive';
5
+ name;
6
+ parameters;
7
+ constructor({
8
+ name,
9
+ parameters,
10
+ ...rest
11
+ }) {
12
+ super({
13
+ ...rest
14
+ });
16
15
  this.name = name;
17
16
  this.parameters = mergeRight({
18
- version: null,
19
- handle: null,
20
- prefix: null
17
+ version: undefined,
18
+ handle: undefined,
19
+ prefix: undefined
21
20
  }, parameters);
22
21
  }
23
- });
22
+ }
24
23
  export default YamlDirective;
@@ -1,8 +1,5 @@
1
- import stampit from 'stampit';
2
1
  import Node from "../../Node.mjs";
3
- const YamlDocument = stampit(Node, {
4
- statics: {
5
- type: 'document'
6
- }
7
- });
2
+ class YamlDocument extends Node {
3
+ static type = 'document';
4
+ }
8
5
  export default YamlDocument;
@@ -1,34 +1,36 @@
1
- import stampit from 'stampit';
2
1
  import Node from "../../Node.mjs";
3
- import YamlStyleModel from "./YamlStyle.mjs";
4
2
  import { isScalar, isMapping, isSequence, isAlias } from "./predicates.mjs";
5
- const YamlKeyValuePair = stampit(Node, YamlStyleModel, {
6
- statics: {
7
- type: 'keyValuePair'
3
+ class YamlKeyValuePair extends Node {
4
+ static type = 'keyValuePair';
5
+ styleGroup;
6
+ constructor({
7
+ styleGroup,
8
+ ...rest
9
+ }) {
10
+ super({
11
+ ...rest
12
+ });
13
+ this.styleGroup = styleGroup;
14
+ }
15
+ }
16
+ Object.defineProperties(YamlKeyValuePair.prototype, {
17
+ key: {
18
+ get() {
19
+ return this.children.filter(node => isScalar(node) || isMapping(node) || isSequence(node))[0];
20
+ },
21
+ enumerable: true
8
22
  },
9
- propertyDescriptors: {
10
- key: {
11
- get() {
12
- // @ts-ignore
13
- return this.children.filter(node => isScalar(node) || isMapping(node) || isSequence(node))[0];
14
- },
15
- enumerable: true
23
+ value: {
24
+ get() {
25
+ const {
26
+ key,
27
+ children
28
+ } = this;
29
+ const excludeKeyPredicate = node => node !== key;
30
+ const valuePredicate = node => isScalar(node) || isMapping(node) || isSequence(node) || isAlias(node);
31
+ return children.filter(node => excludeKeyPredicate(node) && valuePredicate(node))[0];
16
32
  },
17
- value: {
18
- get() {
19
- // @ts-ignore
20
- const {
21
- key,
22
- children
23
- } = this;
24
- const excludeKeyPredicate = node => node !== key;
25
- const valuePredicate = node => isScalar(node) || isMapping(node) || isSequence(node) || isAlias(node);
26
-
27
- // @ts-ignore
28
- return children.filter(node => excludeKeyPredicate(node) && valuePredicate(node))[0];
29
- },
30
- enumerable: true
31
- }
33
+ enumerable: true
32
34
  }
33
35
  });
34
36
  export default YamlKeyValuePair;
@@ -1,18 +1,12 @@
1
- import stampit from 'stampit';
2
1
  import YamlCollection from "./YamlCollection.mjs";
3
2
  import { isKeyValuePair } from "./predicates.mjs";
4
- const YamlMapping = stampit(YamlCollection, {
5
- statics: {
6
- type: 'mapping'
3
+ class YamlMapping extends YamlCollection {
4
+ static type = 'mapping';
5
+ }
6
+ Object.defineProperty(YamlMapping.prototype, 'content', {
7
+ get() {
8
+ return Array.isArray(this.children) ? this.children.filter(isKeyValuePair) : [];
7
9
  },
8
- propertyDescriptors: {
9
- content: {
10
- get() {
11
- // @ts-ignore
12
- return Array.isArray(this.children) ? this.children.filter(isKeyValuePair) : [];
13
- },
14
- enumerable: true
15
- }
16
- }
10
+ enumerable: true
17
11
  });
18
12
  export default YamlMapping;
@@ -1,22 +1,23 @@
1
- import stampit from 'stampit';
2
1
  import Node from "../../Node.mjs";
3
- const YamlNode = stampit(Node, {
4
- props: {
5
- anchor: null,
6
- tag: null,
7
- style: null,
8
- styleGroup: null
9
- },
10
- init({
11
- anchor = null,
12
- tag = null,
13
- style = null,
14
- styleGroup = null
15
- } = {}) {
2
+ class YamlNode extends Node {
3
+ anchor;
4
+ tag;
5
+ style;
6
+ styleGroup;
7
+ constructor({
8
+ anchor,
9
+ tag,
10
+ style,
11
+ styleGroup,
12
+ ...rest
13
+ }) {
14
+ super({
15
+ ...rest
16
+ });
16
17
  this.anchor = anchor;
17
18
  this.tag = tag;
18
19
  this.style = style;
19
20
  this.styleGroup = styleGroup;
20
21
  }
21
- });
22
+ }
22
23
  export default YamlNode;
@@ -1,16 +1,15 @@
1
- import stampit from 'stampit';
2
1
  import YamlNode from "./YamlNode.mjs";
3
- const YamlScalar = stampit(YamlNode, {
4
- statics: {
5
- type: 'scalar'
6
- },
7
- props: {
8
- content: ''
9
- },
10
- init({
11
- content
12
- } = {}) {
2
+ class YamlScalar extends YamlNode {
3
+ static type = 'scalar';
4
+ content;
5
+ constructor({
6
+ content,
7
+ ...rest
8
+ }) {
9
+ super({
10
+ ...rest
11
+ });
13
12
  this.content = content;
14
13
  }
15
- });
14
+ }
16
15
  export default YamlScalar;