null.js 434 B

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