'use strict';

var stemmer;

/**
 * Module dependencies.
 */

stemmer = require('stemmer');

/**
 * `changetextinside` handler;
 *
 * @this Node
 */

function onchangetextinside() {
    var value;

    value = this.toString();

    this.data.stem = value ? stemmer(value) : null;
}

/**
 * Define `porterStemmer`.
 *
 * @param {Retext} retext - Instance of Retext.
 */

function porterStemmer(retext) {
    var WordNode;

    WordNode = retext.parser.TextOM.WordNode;

    WordNode.on('changetextinside', onchangetextinside);
    WordNode.on('removeinside', onchangetextinside);
    WordNode.on('insertinside', onchangetextinside);
}

/**
 * Expose `porterStemmer`.
 */

module.exports = porterStemmer;

'use strict';

var stemmer;

/**
 * Module dependencies.
 */

stemmer = require('stemmer');

/**
 * `changetextinside` handler;
 *
 * @this Node
 */

function onchangeinside() {
    var value;

    value = this.toString();

    this.data.stem = value ? stemmer(value) : null;
}

/**
 * Define `porterStemmer`.
 *
 * @param {Retext} retext - Instance of Retext.
 */

function porterStemmer(retext) {
    retext.TextOM.WordNode.on('changeinside', onchangeinside);
}

/**
 * Expose `porterStemmer`.
 */

module.exports = porterStemmer;

Refactor to use generic `changeinside` in new retext
Refactor to use generic `changeinside` in new retext
