parse.js 389 B

12345678910111213
  1. 'use strict';
  2. const getEngine = require('./engine');
  3. const defaults = require('./defaults');
  4. module.exports = function(language, str, options) {
  5. const opts = defaults(options);
  6. const engine = getEngine(language, opts);
  7. if (typeof engine.parse !== 'function') {
  8. throw new TypeError('expected "' + language + '.parse" to be a function');
  9. }
  10. return engine.parse(str, opts);
  11. };