map.js 483 B

12345678910111213141516171819
  1. 'use strict';
  2. var identity = require('../../nodes/identity.js');
  3. var YAMLMap = require('../../nodes/YAMLMap.js');
  4. const map = {
  5. collection: 'map',
  6. default: true,
  7. nodeClass: YAMLMap.YAMLMap,
  8. tag: 'tag:yaml.org,2002:map',
  9. resolve(map, onError) {
  10. if (!identity.isMap(map))
  11. onError('Expected a mapping for this tag');
  12. return map;
  13. },
  14. createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
  15. };
  16. exports.map = map;