main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 16 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
635 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var Scalar = require('../../nodes/Scalar.js');
|
---|
4 |
|
---|
5 | const boolTag = {
|
---|
6 | identify: value => typeof value === 'boolean',
|
---|
7 | default: true,
|
---|
8 | tag: 'tag:yaml.org,2002:bool',
|
---|
9 | test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
---|
10 | resolve: str => new Scalar.Scalar(str[0] === 't' || str[0] === 'T'),
|
---|
11 | stringify({ source, value }, ctx) {
|
---|
12 | if (source && boolTag.test.test(source)) {
|
---|
13 | const sv = source[0] === 't' || source[0] === 'T';
|
---|
14 | if (value === sv)
|
---|
15 | return source;
|
---|
16 | }
|
---|
17 | return value ? ctx.options.trueStr : ctx.options.falseStr;
|
---|
18 | }
|
---|
19 | };
|
---|
20 |
|
---|
21 | exports.boolTag = boolTag;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.