
package.es.yaml.nodes.YamlKeyValuePair.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apidom-ast Show documentation
Show all versions of apidom-ast Show documentation
Tools necessary for parsing stage of ApiDOM, specifically for syntactic analysis.
The newest version!
import Node from "../../Node.mjs";
import { isScalar, isMapping, isSequence, isAlias } from "./predicates.mjs";
class YamlKeyValuePair extends Node {
static type = 'keyValuePair';
styleGroup;
constructor({
styleGroup,
...rest
}) {
super({
...rest
});
this.styleGroup = styleGroup;
}
}
Object.defineProperties(YamlKeyValuePair.prototype, {
key: {
get() {
return this.children.filter(node => isScalar(node) || isMapping(node) || isSequence(node))[0];
},
enumerable: true
},
value: {
get() {
const {
key,
children
} = this;
const excludeKeyPredicate = node => node !== key;
const valuePredicate = node => isScalar(node) || isMapping(node) || isSequence(node) || isAlias(node);
return children.filter(node => excludeKeyPredicate(node) && valuePredicate(node))[0];
},
enumerable: true
}
});
export default YamlKeyValuePair;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy