var reactMappings = require('./reactMappings');
var valToStr = require('./helpers').valToStr;

function JSXNode(tag, props, children) {
    this.tag = tag || 'div';
    this.props = props || {};
    this.children = children || [];
}

var propsToStr = props => Object.keys(props).map(k => `${k}={${valToStr(props[k])}}`).join(' ');
var tagToClass = tag => reactMappings[tag] ? tag : tag.slice(0, 1).toUpperCase() + tag.slice(1);

JSXNode.prototype.toString = function() {
    var tag = tagToClass(this.tag);
    var str = this.children ?
        `<${tag} ${propsToStr(this.props)}>${[].concat(this.children).join('\n')}</${tag}>` :
        `<${tag} ${propsToStr(this.props)}/>`;
    return str;
};

function transform(bemjson) {
    if (Array.isArray(bemjson)) {
        return bemjson.map(bj => transform(bj));
    }

    var node = new JSXNode();
    bemjson.block && (node.tag = bemjson.block);
    bemjson.block && bemjson.elem && (node.tag = bemjson.block + '__' + bemjson.elem);
    bemjson.tag && (node.tag = bemjson.tag);
    bemjson.mods && Object.assign(node.props, bemjson.mods);

    var blackList = ['content', 'block', 'elem', 'mods', 'tag', 'js'];

    Object.keys(bemjson).forEach(k => {
        if(~blackList.indexOf(k)) { return; }

        node.props[k] = bemjson[k];
    });

    node.children = bemjson.content && transform(bemjson.content);

    return node;
}

function Transformer() {
    this.plugins = [];
}

Transformer.prototype.use = function(...plugins) {
    this.plugins.push(plugins);
    return this;
};

Transformer.prototype.process = function(bemjson) {
    var tree = transform(bemjson);
    this.plugins.forEach(plugin => {
        plugin(tree);
    });
    return {
        tree: tree,
        get JSX() {
            return render(this.tree);
        }
    }
};

function render(tree) {
    return Array.isArray(tree) ?
        tree.join('\n') :
        tree.toString();
}

module.exports = function() {
    return new Transformer();
};

@@ -1468,53 +1468,54 @@
 ion(
-...plugins) %7B%0A    this.plugins.push(plugin
+) %7B%0A    %5B%5D.push.apply(this.plugins, argument
 s)
-;
 %0A   
@@ -1792,16 +1792,17 @@
  %7D%0A    %7D
+;
 %0A%7D;%0A%0Afun
@@ -1909,16 +1909,66 @@
 g();%0A%7D%0A%0A
+Transformer.prototype.Transformer = Transformer;%0A%0A
 module.e

Fix after review