main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
938 bytes
|
Line | |
---|
1 | import Node from "../../Node.mjs";
|
---|
2 | import { isScalar, isMapping, isSequence, isAlias } from "./predicates.mjs";
|
---|
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
|
---|
22 | },
|
---|
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];
|
---|
32 | },
|
---|
33 | enumerable: true
|
---|
34 | }
|
---|
35 | });
|
---|
36 | export default YamlKeyValuePair; |
---|
Note:
See
TracBrowser
for help on using the repository browser.