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:
842 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var Scalar = require('../../nodes/Scalar.js');
|
---|
| 4 |
|
---|
| 5 | function boolStringify({ value, source }, ctx) {
|
---|
| 6 | const boolObj = value ? trueTag : falseTag;
|
---|
| 7 | if (source && boolObj.test.test(source))
|
---|
| 8 | return source;
|
---|
| 9 | return value ? ctx.options.trueStr : ctx.options.falseStr;
|
---|
| 10 | }
|
---|
| 11 | const trueTag = {
|
---|
| 12 | identify: value => value === true,
|
---|
| 13 | default: true,
|
---|
| 14 | tag: 'tag:yaml.org,2002:bool',
|
---|
| 15 | test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
---|
| 16 | resolve: () => new Scalar.Scalar(true),
|
---|
| 17 | stringify: boolStringify
|
---|
| 18 | };
|
---|
| 19 | const falseTag = {
|
---|
| 20 | identify: value => value === false,
|
---|
| 21 | default: true,
|
---|
| 22 | tag: 'tag:yaml.org,2002:bool',
|
---|
| 23 | test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
---|
| 24 | resolve: () => new Scalar.Scalar(false),
|
---|
| 25 | stringify: boolStringify
|
---|
| 26 | };
|
---|
| 27 |
|
---|
| 28 | exports.falseTag = falseTag;
|
---|
| 29 | exports.trueTag = trueTag;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.