null.js 469 B

1234567891011121314151617
  1. 'use strict';
  2. var Scalar = require('../../nodes/Scalar.js');
  3. const nullTag = {
  4. identify: value => value == null,
  5. createNode: () => new Scalar.Scalar(null),
  6. default: true,
  7. tag: 'tag:yaml.org,2002:null',
  8. test: /^(?:~|[Nn]ull|NULL)?$/,
  9. resolve: () => new Scalar.Scalar(null),
  10. stringify: ({ source }, ctx) => typeof source === 'string' && nullTag.test.test(source)
  11. ? source
  12. : ctx.options.nullStr
  13. };
  14. exports.nullTag = nullTag;