index.js
 1  'use strict';
 2  
 3  const Parser = require('./parser');
 4  const Serializer = require('./serializer');
 5  
 6  // Shorthands
 7  exports.parse = function parse(html, options) {
 8      const parser = new Parser(options);
 9  
10      return parser.parse(html);
11  };
12  
13  exports.parseFragment = function parseFragment(fragmentContext, html, options) {
14      if (typeof fragmentContext === 'string') {
15          options = html;
16          html = fragmentContext;
17          fragmentContext = null;
18      }
19  
20      const parser = new Parser(options);
21  
22      return parser.parseFragment(html, fragmentContext);
23  };
24  
25  exports.serialize = function(node, options) {
26      const serializer = new Serializer(node, options);
27  
28      return serializer.serialize();
29  };