yaml-ast-parser
Version:
[](https://travis-ci.org/mulesoft-labs/yaml-ast-parser)
39 lines (29 loc) • 764 B
text/typescript
import {Type} from '../type';
function resolveYamlNull(data) {
if (null === data) {
return true;
}
var max = data.length;
return (max === 1 && data === '~') ||
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
}
function constructYamlNull() {
return null;
}
function isNull(object) {
return null === object;
}
export = new Type('tag:yaml.org,2002:null', {
kind: 'scalar',
resolve: resolveYamlNull,
construct: constructYamlNull,
predicate: isNull,
represent: {
canonical: function () { return '~'; },
lowercase: function () { return 'null'; },
uppercase: function () { return 'NULL'; },
camelcase: function () { return 'Null'; }
},
defaultStyle: 'lowercase'
});
;