UNPKG

dav

Version:

WebDAV, CalDAV, and CardDAV client for nodejs and the browser

70 lines (63 loc) 1.64 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports['default'] = prop; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } var _namespace = require('../namespace'); var ns = _interopRequireWildcard(_namespace); /** * @param {Object} filter looks like * * { * type: 'comp-filter', * attrs: { * name: 'VCALENDAR' * } * } * * Or maybe * * { * type: 'time-range', * attrs: { * start: '20060104T000000Z', * end: '20060105T000000Z' * } * } * * You can nest them like so: * * { * type: 'comp-filter', * attrs: { name: 'VCALENDAR' }, * children: [{ * type: 'comp-filter', * attrs: { name: 'VEVENT' }, * children: [{ * type: 'time-range', * attrs: { start: '20060104T000000Z', end: '20060105T000000Z' } * }] * }] * } */ function prop(item) { return '<' + xmlnsPrefix(item.namespace) + ':' + item.name + ' />'; } function xmlnsPrefix(namespace) { switch (namespace) { case ns.DAV: return 'd'; case ns.CALENDAR_SERVER: return 'cs'; case ns.CALDAV_APPLE: return 'ca'; case ns.CALDAV: return 'c'; case ns.CARDDAV: return 'card'; default: throw new Error('Unrecognized xmlns ' + namespace); } } module.exports = exports['default'];