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:
759 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var identity = require('./identity.js');
|
---|
4 | var Node = require('./Node.js');
|
---|
5 | var toJS = require('./toJS.js');
|
---|
6 |
|
---|
7 | const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
---|
8 | class Scalar extends Node.NodeBase {
|
---|
9 | constructor(value) {
|
---|
10 | super(identity.SCALAR);
|
---|
11 | this.value = value;
|
---|
12 | }
|
---|
13 | toJSON(arg, ctx) {
|
---|
14 | return ctx?.keep ? this.value : toJS.toJS(this.value, arg, ctx);
|
---|
15 | }
|
---|
16 | toString() {
|
---|
17 | return String(this.value);
|
---|
18 | }
|
---|
19 | }
|
---|
20 | Scalar.BLOCK_FOLDED = 'BLOCK_FOLDED';
|
---|
21 | Scalar.BLOCK_LITERAL = 'BLOCK_LITERAL';
|
---|
22 | Scalar.PLAIN = 'PLAIN';
|
---|
23 | Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
---|
24 | Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
---|
25 |
|
---|
26 | exports.Scalar = Scalar;
|
---|
27 | exports.isScalarValue = isScalarValue;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.