<commit_before>'use strict';

/*
 * Dependencies..
 */

var Ware;

Ware = require('ware');

/*
 * Components.
 */

var parse,
    stringify;

parse = require('./lib/parse.js');
stringify = require('./lib/stringify.js');

/**
 * Construct an MDAST instance.
 *
 * @constructor {MDAST}
 */
function MDAST() {
    this.ware = new Ware();
}

/**
 * Parse a value and apply plugins.
 *
 * @return {Root}
 */
function runParse(_, options) {
    var node;

    node = parse.apply(parse, arguments);

    this.ware.run(node, options);

    return node;
}

/**
 * Construct an MDAST instance and use a plugin.
 *
 * @return {MDAST}
 */
function use(plugin) {
    var self;

    self = this;

    if (!(self instanceof MDAST)) {
        self = new MDAST();
    }

    self.ware.use(plugin);

    return self;
}

/*
 * Prototype.
 */

MDAST.prototype.parse = runParse;
MDAST.prototype.stringify = stringify;<commit_msg>Add throwing on errors in plug-ins<commit_after>'use strict';

/*
 * Dependencies..
 */

var Ware;

Ware = require('ware');

/*
 * Components.
 */

var parse,
    stringify;

parse = require('./lib/parse.js');
stringify = require('./lib/stringify.js');

/**
 * Throws if passed an exception.
 *
 * Here until the following PR is merged into
 * segmentio/ware:
 *
 *   https://github.com/segmentio/ware/pull/21
 *
 * @param {Error?} exception
 */
function fail(exception) {
    if (exception) {
        throw exception;
    }
}

/**
 * Construct an MDAST instance.
 *
 * @constructor {MDAST}
 */
function MDAST() {
    this.ware = new Ware();
}

/**
 * Parse a value and apply plugins.
 *
 * @return {Root}
 */
function runParse(_, options) {
    var node;

    node = parse.apply(parse, arguments);

    this.ware.run(node, options, fail);

    return node;
}

/**
 * Construct an MDAST instance and use a plugin.
 *
 * @return {MDAST}
 */
function use(plugin) {
    var self;

    self = this;

    if (!(self instanceof MDAST)) {
        self = new MDAST();
    }

    self.ware.use(plugin);

    return self;
}

/*
 * Prototype.
 */

MDAST.prototype.parse = runParse;
MDAST.prototype.stringify = stringify;
{'fraction_non_alphanumeric': 0.16013226263580538, 'fraction_numerical': 0.000944733112895607, 'mean_word_length': 2.6707105719237436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6549019', 'n_tokens_mistral': 732, 'n_tokens_neox': 705, 'n_words': 183}