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:
467 bytes
|
Line | |
---|
1 | import JsonNode from "./JsonNode.mjs";
|
---|
2 | import { isEscapeSequence, isStringContent } from "./predicates.mjs";
|
---|
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;
|
---|
9 | }
|
---|
10 | return this.children.filter(node => isStringContent(node) || isEscapeSequence(node)).reduce((acc, cur) => acc + cur.value, '');
|
---|
11 | }
|
---|
12 | }
|
---|
13 | export default JsonString; |
---|
Note:
See
TracBrowser
for help on using the repository browser.