You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
714 B
26 lines
714 B
'use strict'; |
|
|
|
var Node = require('./Node.js'); |
|
var toJS = require('./toJS.js'); |
|
|
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object'); |
|
class Scalar extends Node.NodeBase { |
|
constructor(value) { |
|
super(Node.SCALAR); |
|
this.value = value; |
|
} |
|
toJSON(arg, ctx) { |
|
return ctx?.keep ? this.value : toJS.toJS(this.value, arg, ctx); |
|
} |
|
toString() { |
|
return String(this.value); |
|
} |
|
} |
|
Scalar.BLOCK_FOLDED = 'BLOCK_FOLDED'; |
|
Scalar.BLOCK_LITERAL = 'BLOCK_LITERAL'; |
|
Scalar.PLAIN = 'PLAIN'; |
|
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE'; |
|
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE'; |
|
|
|
exports.Scalar = Scalar; |
|
exports.isScalarValue = isScalarValue;
|
|
|