<commit_before>var jQuery = require('jquery');
var VIE = require('../vie.js');

// Until https://github.com/tmpvar/jsdom/issues/issue/81 is fixed you need to uncomment the following:
//VIE.RDFa.predicateSelector = '[property]';

exports['test inheriting subject'] = function(test) {
    var html = jQuery('
Albert Einstein1879-03-14
Federal Republic of Germany
');

    var jsonldEntities = VIE.RDFa.readEntities(html);
    test.equal(jsonldEntities.length, 2, "This RDFa defines two entities but they don't get parsed to JSON");

    test.equal(jsonldEntities[1]['foaf:name'], 'Albert Einstein');
    test.equal(jsonldEntities[0]['dbp:conventionalLongName'], 'Federal Republic of Germany');
    test.equals(jsonldEntities[1]['dbp:birthPlace'], '<' + jsonldEntities[0]['@'] + '>', "Check that the relation between the person and the birthplace was read correctly");

    var backboneEntities = VIE.RDFaEntities.getInstances(html);
    test.equal(backboneEntities.length, 2, "This RDFa defines two entities but they don't get to Backbone");

    test.equal(backboneEntities[1].get('foaf:name'), 'Albert Einstein');
    test.equal(backboneEntities[0].get('dbp:conventionalLongName'), 'Federal Republic of Germany');

    VIE.cleanup();
    test.done();
};

exports['test subject singletons'] = function(test) {
   var html = jQuery('
Albert Einstein1879-03-14
Federal Republic of Germany
');

    var backboneEntities = VIE.RDFaEntities.getInstances(html);

    test.equal(backboneEntities[1].get('foaf:name'), 'Albert Einstein');

    var individualInstance = VIE.EntityManager.getBySubject('http://dbpedia.org/resource/Albert_Einstein');
    test.equal(individualInstance.get('foaf:name'), 'Albert Einstein');

    individualInstance.set({'foaf:name': 'Al Einstein'});
    test.equal(backboneEntities[1].get('foaf:name'), 'Al Einstein');

    // And then the interesting bit, check that it changed in the HTML as well
    jQuery('[property="foaf:name"]', html).each(function() {
        test.equal(jQuery(this).html(), 'Al Einstein', 'Check that the change actually affected the HTML');
    });

    VIE.cleanup();
    test.done();
};

exports['test updating views'] = function(test) {
    var html = jQuery('
Albert Einstein1879-03-14
Federal Republic of Germany
');

    var backboneEntities = VIE.RDFaEntities.getInstances(html);

    // Ensure we got the value
    test.equal(backboneEntities[0].get('dbp:conventionalLongName'), 'Federal Republic of Germany');

    // Change the value
    backboneEntities[0].set({'dbp:conventionalLongName': 'Switzerland'});

    // Ensure that it was changed in the model
    test.equal(backboneEntities[0].get('dbp:conventionalLongName'), 'Switzerland');

    // And then the interesting bit, check that it changed in the HTML as well
    jQuery('[property="dbp:conventionalLongName"]', html).each(function() {
        test.equal(jQuery(this).html(), 'Switzerland', 'Check that the change actually affected the HTML');
    });

    VIE.cleanup();
    test.done();
};

exports['test global entity'] = function(test) {
    var html = jQuery('<title>Jo\'s Friends and Family Blog</title><link rel="foaf:primaryTopic" href="#bbq" /><meta property="dc:creator" content="Jo" />...');

    var jsonldEntities = VIE.RDFa.readEntities(html);

    // We should find the dc:creator from this. Unfortunately there is no subject as this isn't on browser
    test.equal(jsonldEntities.length, 1);
    test.equal(jsonldEntities[0]['dc:creator'], 'Jo');
    test.equal(jsonldEntities[0]['@'], undefined);
    VIE.cleanup();

    var html = jQuery('<title>Jo\'s Blog</title>
Jo\'s blog

Welcome to my blog.
');

   var jsonldEntities = VIE.RDFa.readEntities(html);

    // We should find the dc:creator from this. Unfortunately there is no subject as this isn't on browser
    test.equal(jsonldEntities.length, 1);
    test.equal(jsonldEntities[0]['dc:creator'], 'Jo');

    VIE.cleanup();
    test.done();
};

exports['test global entity with base URL'] = function(test) {
    var html = jQuery('<base href="http://www.example.org/jo/blog" /><title>Jo\'s Friends and Family Blog</title><link rel="foaf:primaryTopic" href="#bbq" /><meta property="dc:creator" content="Jo" />...');

    var jsonldEntities = VIE.RDFa.readEntities(html);

    // We should find the dc:creator from this. Unfortunately there is no subject as this isn't on browser
    test.equal(jsonldEntities.length, 1);
    test.equal(jsonldEntities[0]['dc:creator'], 'Jo');
    test.equal(jsonldEntities[0]['@'], 'http://www.example.org/jo/blog');

    VIE.cleanup();
    test.done();
};

exports['test about and anonymous'] = function(test) {
    var html = jQuery('<title>Jo\'s Friends and Family Blog</title><link rel="foaf:primaryTopic" href="#bbq" /><meta property="dc:creator" content="Jo" />
I\'m holdingone last summer barbecue, on September 16th at 4pm.
');

    var jsonldEntities = VIE.RDFa.readEntities(html);

    test.equal(jsonldEntities.length, 2);
    test.equal(jsonldEntities[0]['a'], 'cal:Vevent');
    // FIXME: This should really have the datatype
    test.equal(jsonldEntities[0]['cal:dtstart'], '2007-09-16T16:00:00-05:00');

    VIE.cleanup();
    test.done();
};

exports['test example from README'] = function(test) {
    var html = jQuery('

News item title

News item contents

');

    var objectInstance = VIE.RDFaEntities.getInstance(html);

    test.equal(objectInstance.get('dcterms:title'), 'News item title');

    objectInstance.set({'dcterms:title': 'Hello, world'});

    test.equal(objectInstance.get('dcterms:title'), 'Hello, world');

    // And then the interesting bit, check that it changed in the HTML as well
    jQuery('[property="dcterms:title"]', html).each(function() {
        test.equal(jQuery(this).html(), 'Hello, world', 'Check that the change actually affected the HTML');
    });

    VIE.cleanup();
    test.done();
};
<commit_msg>Add another test from Wikipedia RDFa page<commit_after>var jQuery = require('jquery');
var VIE = require('../vie.js');

// Until https://github.com/tmpvar/jsdom/issues/issue/81 is fixed you need to uncomment the following:
//VIE.RDFa.predicateSelector = '[property]';

exports['test inheriting subject'] = function(test) {
    var html = jQuery('
Albert Einstein1879-03-14
Federal Republic of Germany
');

    var jsonldEntities = VIE.RDFa.readEntities(html);
    test.equal(jsonldEntities.length, 2, "This RDFa defines two entities but they don't get parsed to JSON");

    test.equal(jsonldEntities[1]['foaf:name'], 'Albert Einstein');
    test.equal(jsonldEntities[0]['dbp:conventionalLongName'], 'Federal Republic of Germany');
    test.equals(jsonldEntities[1]['dbp:birthPlace'], '<' + jsonldEntities[0]['@'] + '>', "Check that the relation between the person and the birthplace was read correctly");

    var backboneEntities = VIE.RDFaEntities.getInstances(html);
    test.equal(backboneEntities.length, 2, "This RDFa defines two entities but they don't get to Backbone");

    test.equal(backboneEntities[1].get('foaf:name'), 'Albert Einstein');
    test.equal(backboneEntities[0].get('dbp:conventionalLongName'), 'Federal Republic of Germany');

    VIE.cleanup();
    test.done();
};

exports['test subject singletons'] = function(test) {
   var html = jQuery('
Albert Einstein1879-03-14
Federal Republic of Germany
');

    var backboneEntities = VIE.RDFaEntities.getInstances(html);

    test.equal(backboneEntities[1].get('foaf:name'), 'Albert Einstein');

    var individualInstance = VIE.EntityManager.getBySubject('http://dbpedia.org/resource/Albert_Einstein');
    test.equal(individualInstance.get('foaf:name'), 'Albert Einstein');

    individualInstance.set({'foaf:name': 'Al Einstein'});
    test.equal(backboneEntities[1].get('foaf:name'), 'Al Einstein');

    // And then the interesting bit, check that it changed in the HTML as well
    jQuery('[property="foaf:name"]', html).each(function() {
        test.equal(jQuery(this).html(), 'Al Einstein', 'Check that the change actually affected the HTML');
    });

    VIE.cleanup();
    test.done();
};

exports['test updating views'] = function(test) {
    var html = jQuery('
Albert Einstein1879-03-14
Federal Republic of Germany
');

    var backboneEntities = VIE.RDFaEntities.getInstances(html);

    // Ensure we got the value
    test.equal(backboneEntities[0].get('dbp:conventionalLongName'), 'Federal Republic of Germany');

    // Change the value
    backboneEntities[0].set({'dbp:conventionalLongName': 'Switzerland'});

    // Ensure that it was changed in the model
    test.equal(backboneEntities[0].get('dbp:conventionalLongName'), 'Switzerland');

    // And then the interesting bit, check that it changed in the HTML as well
    jQuery('[property="dbp:conventionalLongName"]', html).each(function() {
        test.equal(jQuery(this).html(), 'Switzerland', 'Check that the change actually affected the HTML');
    });

    VIE.cleanup();
    test.done();
};

exports['test global entity'] = function(test) {
    var html = jQuery('<title>Jo\'s Friends and Family Blog</title><link rel="foaf:primaryTopic" href="#bbq" /><meta property="dc:creator" content="Jo" />...');

    var jsonldEntities = VIE.RDFa.readEntities(html);

    // We should find the dc:creator from this. Unfortunately there is no subject as this isn't on browser
    test.equal(jsonldEntities.length, 1);
    test.equal(jsonldEntities[0]['dc:creator'], 'Jo');
    test.equal(jsonldEntities[0]['@'], undefined);
    VIE.cleanup();

    var html = jQuery('<title>Jo\'s Blog</title>
Jo\'s blog

Welcome to my blog.
');

   var jsonldEntities = VIE.RDFa.readEntities(html);

    // We should find the dc:creator from this. Unfortunately there is no subject as this isn't on browser
    test.equal(jsonldEntities.length, 1);
    test.equal(jsonldEntities[0]['dc:creator'], 'Jo');

    VIE.cleanup();
    test.done();
};

exports['test global entity with base URL'] = function(test) {
    var html = jQuery('<base href="http://www.example.org/jo/blog" /><title>Jo\'s Friends and Family Blog</title><link rel="foaf:primaryTopic" href="#bbq" /><meta property="dc:creator" content="Jo" />...');

    var jsonldEntities = VIE.RDFa.readEntities(html);

    // We should find the dc:creator from this. Unfortunately there is no subject as this isn't on browser
    test.equal(jsonldEntities.length, 1);
    test.equal(jsonldEntities[0]['dc:creator'], 'Jo');
    test.equal(jsonldEntities[0]['@'], 'http://www.example.org/jo/blog');

    VIE.cleanup();
    test.done();
};

exports['test about and anonymous'] = function(test) {
    var html = jQuery('<title>Jo\'s Friends and Family Blog</title><link rel="foaf:primaryTopic" href="#bbq" /><meta property="dc:creator" content="Jo" />
I\'m holdingone last summer barbecue, on September 16th at 4pm.
');

    var jsonldEntities = VIE.RDFa.readEntities(html);

    test.equal(jsonldEntities.length, 2);
    test.equal(jsonldEntities[0]['a'], 'cal:Vevent');
    // FIXME: This should really have the datatype
    test.equal(jsonldEntities[0]['cal:dtstart'], '2007-09-16T16:00:00-05:00');

    VIE.cleanup();
    test.done();
};

exports['test example from README'] = function(test) {
    var html = jQuery('

News item title

News item contents

');

    var objectInstance = VIE.RDFaEntities.getInstance(html);

    test.equal(objectInstance.get('dcterms:title'), 'News item title');

    objectInstance.set({'dcterms:title': 'Hello, world'});

    test.equal(objectInstance.get('dcterms:title'), 'Hello, world');

    // And then the interesting bit, check that it changed in the HTML as well
    jQuery('[property="dcterms:title"]', html).each(function() {
        test.equal(jQuery(this).html(), 'Hello, world', 'Check that the change actually affected the HTML');
    });

    VIE.cleanup();
    test.done();
};

exports['test example from wikipedia'] = function(test) {
    var html = jQuery('
In his latest book Wikinomics, Don Tapscott explains deep changes in technology, demographics and business. The book is due to be published in October 2006.
');

    VIE.RDFaEntities.getInstances(html);
    var objectInstance = VIE.EntityManager.getBySubject('http://www.example.com/books/wikinomics');
    test.equal(objectInstance.get('dc:title'), 'Wikinomics');
    test.equal(objectInstance.get('dc:creator'), 'Don Tapscott');

    VIE.cleanup();
    test.done();
};
<|endoftext|>


<commit_before><commit_msg>add test case for image type<commit_after><|endoftext|>


<commit_before><commit_msg>Added more basic unit tests<commit_after><|endoftext|>


<commit_before><commit_msg>Now testing both native and polyfill<commit_after><|endoftext|>


<commit_before><commit_msg>add content/links test<commit_after><|endoftext|>


<commit_before>var assert = require('assert');
var Cmap = require('../cmap.js');

describe('Cmap', function() {
  it('#createNode', function() {
    var cmap = new Cmap();
    var props = {
      content: 'node',
      x: 100,
      y: 200,
      width: 120,
      height: 45,
      backgroundColor: 'white',
      borderColor: 'black',
      borderWidth: 4,
      textColor: 'black'
    };
    var node = cmap.createNode(props);
    for (var key in props) {
      assert.equal(node[key](), props[key]);
    }
    node = cmap.createNode();
    for (var key in props) {
      var value = props[key];
      node[key](value);
      assert.equal(node[key](), value);
    }
  });

  it('#createLink', function() {
    var cmap = new Cmap();
    var props = {
      content: 'link',
      cx: 100,
      cy: 200,
      width: 120,
      height: 45,
      backgroundColor: 'black',
      borderColor: 'white',
      borderWidth: 4,
      textColor: 'white',
      sourceX: 50,
      sourceY: 100,
      targetX: 150,
      targetY: 300,
      lineColor: 'white',
      lineWidth: 4,
      hasArrow: true
    };
    var link = cmap.createLink(props);
    for (var key in props) {
      assert.equal(link[key](), props[key]);
    }
    link = cmap.createLink();
    for (var key in props) {
      var value = props[key];
      link[key](value);
      assert.equal(link[key](), value);
    }
  });

  it('#add', function() {
    var dummy = {};
    var cmap = new Cmap(dummy);
    var node = cmap.createNode();
    var link = cmap.createLink();
    cmap.add(node);
    cmap.add(link);
    assert.equal(cmap.element(), dummy);
    assert.equal(cmap.element(), node.parentElement());
    assert.equal(cmap.element(), link.parentElement());
  });

  it('#remove', function() {
    var dummy = {};
    var cmap = new Cmap(dummy);
    var node = cmap.createNode();
    var link = cmap.createLink();
    cmap.add(node);
    cmap.add(link);
    cmap.remove(node);
    cmap.remove(link);
    assert.equal(cmap.element(), dummy);
    assert.equal(node.parentElement(), null);
    assert.equal(link.parentElement(), null);
  });

  it('#remove - connection', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var sourceNode = cmap.createNode();
    var targetNode = cmap.createNode();
    cmap.connect(Cmap.CONNECTION_TYPE_SOURCE, sourceNode, link);
    cmap.connect(Cmap.CONNECTION_TYPE_TARGET, targetNode, link);
    cmap.remove(sourceNode);
    var triple = link.relations()[0];
    assert.equal(triple.sourceNode(), null);
    cmap.remove(link);
    assert.equal(targetNode.relations().length, 0);
  });

  it('#connect', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var sourceNode = cmap.createNode();
    var targetNode = cmap.createNode();
    var linkRelations = link.relations();
    var sourceNodeRelations = sourceNode.relations();
    var targetNodeRelations = targetNode.relations();
    cmap.connect(Cmap.CONNECTION_TYPE_SOURCE, sourceNode, link);
    var triple = sourceNodeRelations[0];
    assert.equal(triple, linkRelations[0]);
    assert.equal(triple.sourceNode(), sourceNode);
    assert.equal(triple.link(), link);
    assert.equal(triple.targetNode(), null);
    cmap.connect(Cmap.CONNECTION_TYPE_TARGET, targetNode, link);
    assert.equal(triple, targetNodeRelations[0]);
    assert.equal(triple.targetNode(), targetNode);
  });

  it('#disconnect', function() {
    var cmap = new Cmap();
    var node = cmap.createNode();
    var link = cmap.createLink();
    cmap.connect(Cmap.CONNECTION_TYPE_SOURCE, node, link);
    cmap.disconnect(Cmap.CONNECTION_TYPE_SOURCE, node, link);
    assert.equal(node.relations().length, 0);
    assert.equal(link.relations().length, 0);
  });

  it('#showConnectors', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var linkRelations = link.relations();
    cmap.showConnectors(link);
    assert.equal(linkRelations.length, 2);
    assert.equal(linkRelations[0].link(), link);
    assert.equal(linkRelations[1].link(), link);
    cmap.showConnectors(link);
    assert.equal(linkRelations.length, 2);
  });

  it('#hideConnectors', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var linkRelations = link.relations();
    cmap.showConnectors(link);
    cmap.hideConnectors(link);
    assert.equal(linkRelations.length, 0);
  })
});<commit_msg>Add a semicolon<commit_after>var assert = require('assert');
var Cmap = require('../cmap.js');

describe('Cmap', function() {
  it('#createNode', function() {
    var cmap = new Cmap();
    var props = {
      content: 'node',
      x: 100,
      y: 200,
      width: 120,
      height: 45,
      backgroundColor: 'white',
      borderColor: 'black',
      borderWidth: 4,
      textColor: 'black'
    };
    var node = cmap.createNode(props);
    for (var key in props) {
      assert.equal(node[key](), props[key]);
    }
    node = cmap.createNode();
    for (var key in props) {
      var value = props[key];
      node[key](value);
      assert.equal(node[key](), value);
    }
  });

  it('#createLink', function() {
    var cmap = new Cmap();
    var props = {
      content: 'link',
      cx: 100,
      cy: 200,
      width: 120,
      height: 45,
      backgroundColor: 'black',
      borderColor: 'white',
      borderWidth: 4,
      textColor: 'white',
      sourceX: 50,
      sourceY: 100,
      targetX: 150,
      targetY: 300,
      lineColor: 'white',
      lineWidth: 4,
      hasArrow: true
    };
    var link = cmap.createLink(props);
    for (var key in props) {
      assert.equal(link[key](), props[key]);
    }
    link = cmap.createLink();
    for (var key in props) {
      var value = props[key];
      link[key](value);
      assert.equal(link[key](), value);
    }
  });

  it('#add', function() {
    var dummy = {};
    var cmap = new Cmap(dummy);
    var node = cmap.createNode();
    var link = cmap.createLink();
    cmap.add(node);
    cmap.add(link);
    assert.equal(cmap.element(), dummy);
    assert.equal(cmap.element(), node.parentElement());
    assert.equal(cmap.element(), link.parentElement());
  });

  it('#remove', function() {
    var dummy = {};
    var cmap = new Cmap(dummy);
    var node = cmap.createNode();
    var link = cmap.createLink();
    cmap.add(node);
    cmap.add(link);
    cmap.remove(node);
    cmap.remove(link);
    assert.equal(cmap.element(), dummy);
    assert.equal(node.parentElement(), null);
    assert.equal(link.parentElement(), null);
  });

  it('#remove - connection', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var sourceNode = cmap.createNode();
    var targetNode = cmap.createNode();
    cmap.connect(Cmap.CONNECTION_TYPE_SOURCE, sourceNode, link);
    cmap.connect(Cmap.CONNECTION_TYPE_TARGET, targetNode, link);
    cmap.remove(sourceNode);
    var triple = link.relations()[0];
    assert.equal(triple.sourceNode(), null);
    cmap.remove(link);
    assert.equal(targetNode.relations().length, 0);
  });

  it('#connect', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var sourceNode = cmap.createNode();
    var targetNode = cmap.createNode();
    var linkRelations = link.relations();
    var sourceNodeRelations = sourceNode.relations();
    var targetNodeRelations = targetNode.relations();
    cmap.connect(Cmap.CONNECTION_TYPE_SOURCE, sourceNode, link);
    var triple = sourceNodeRelations[0];
    assert.equal(triple, linkRelations[0]);
    assert.equal(triple.sourceNode(), sourceNode);
    assert.equal(triple.link(), link);
    assert.equal(triple.targetNode(), null);
    cmap.connect(Cmap.CONNECTION_TYPE_TARGET, targetNode, link);
    assert.equal(triple, targetNodeRelations[0]);
    assert.equal(triple.targetNode(), targetNode);
  });

  it('#disconnect', function() {
    var cmap = new Cmap();
    var node = cmap.createNode();
    var link = cmap.createLink();
    cmap.connect(Cmap.CONNECTION_TYPE_SOURCE, node, link);
    cmap.disconnect(Cmap.CONNECTION_TYPE_SOURCE, node, link);
    assert.equal(node.relations().length, 0);
    assert.equal(link.relations().length, 0);
  });

  it('#showConnectors', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var linkRelations = link.relations();
    cmap.showConnectors(link);
    assert.equal(linkRelations.length, 2);
    assert.equal(linkRelations[0].link(), link);
    assert.equal(linkRelations[1].link(), link);
    cmap.showConnectors(link);
    assert.equal(linkRelations.length, 2);
  });

  it('#hideConnectors', function() {
    var cmap = new Cmap();
    var link = cmap.createLink();
    var linkRelations = link.relations();
    cmap.showConnectors(link);
    cmap.hideConnectors(link);
    assert.equal(linkRelations.length, 0);
  });
});<|endoftext|>


<commit_before>var postcss = require('postcss');
var expect  = require('chai').expect;

var plugin = require('../');

var test = function (input, output, opts, done) {
    postcss([ plugin(opts) ]).process(input).then(function (result) {
        expect(result.css).to.eql(output);
        expect(result.warnings()).to.be.empty;
        done();
    }).catch(function (error) {
        done(error);
    });
};

describe('postcss-spine', function () {

    /* Write tests here

    it('does something', function (done) {
        test('a{ }', 'a{ }', { }, done);
    });*/

});
<commit_msg>first test<commit_after>var postcss = require('postcss');
var expect  = require('chai').expect;

var plugin = require('../');

var test = function (input, output, opts, done) {
    postcss([ plugin(opts) ]).process(input).then(function (result) {
        expect(result.css).to.eql(output);
        expect(result.warnings()).to.be.empty;
        done();
    }).catch(function (error) {
        done(error);
    });
};

describe('postcss-spine', function () {

    it('does something', function (done) {
        test('a{ background-color:red }', 'a{ background-color:#fff }', { fallback:true }, done);
    });

});<|endoftext|>


<commit_before><commit_msg>more tests<commit_after><|endoftext|>


<commit_before><commit_msg>adapted tests to new hasAccess function signature<commit_after><|endoftext|>


<commit_before><commit_msg>Make it possible to use options with `executePlugin`<commit_after><|endoftext|>


<commit_before>var parser = require('..');
var describe = require('mocha').describe;
var it = require('mocha').it;
var expect = require('chai').expect;
var path = require('path');
var fs = require('fs');
var html = fs.readFileSync(path.resolve(__dirname, 'templates/render.html'), 'utf8').toString();
var tree = require('./templates/parser.js');

describe('PostHTML-Parser test', function() {
    it('html to tree', function() {
        expect(parser(html)).to.eql(tree);
    });

    it('should be parse comment', function() {
        expect(parser('')).to.eql(['']);
    });

    it('should be parse comment in content', function() {
        expect(parser('

')).to.eql([{tag: 'div', content: ['']}]);
    });

    it('should be parse doctype', function() {
        expect(parser('<!doctype html>')).to.eql(['<!doctype html>']);
    });

    it('should be parse tag', function() {
        expect(parser('')).to.eql([{ tag: 'html' }]);
    });

    it('should be parse doctype and tag', function() {
        expect(parser('<!doctype html>')).to.eql(['<!doctype html>', { tag: 'html' }]);
    });

    it('should be parse tag attrs', function() {
        expect(parser('

')).to.eql([{
            tag: 'div', attrs: { id: 'id', class: 'class'} }
        ]);
    });
});
<commit_msg>tests for texts<commit_after>var parser = require('..');
var describe = require('mocha').describe;
var it = require('mocha').it;
var expect = require('chai').expect;
var path = require('path');
var fs = require('fs');
var html = fs.readFileSync(path.resolve(__dirname, 'templates/render.html'), 'utf8').toString();
var tree = require('./templates/parser.js');

describe('PostHTML-Parser test', function() {
    it('html to tree', function() {
        expect(parser(html)).to.eql(tree);
    });

    it('should be parse comment', function() {
        expect(parser('')).to.eql(['']);
    });

    it('should be parse comment in content', function() {
        expect(parser('

')).to.eql([{tag: 'div', content: ['']}]);
    });

    it('should be parse doctype', function() {
        expect(parser('<!doctype html>')).to.eql(['<!doctype html>']);
    });

    it('should be parse tag', function() {
        expect(parser('')).to.eql([{ tag: 'html' }]);
    });

    it('should be parse doctype and tag', function() {
        expect(parser('<!doctype html>')).to.eql(['<!doctype html>', { tag: 'html' }]);
    });

    it('should be parse tag attrs', function() {
        expect(parser('

')).to.eql([{
            tag: 'div', attrs: { id: 'id', class: 'class'} }
        ]);
    });

    it('should be parse text', function() {
        expect(parser('Text')).to.eql(['Text']);
    });

    it('should be parse text in content', function() {
        expect(parser('
Text
')).to.eql([{ tag: 'div', content: ['Text'] }]);
    });
});
<|endoftext|>


<commit_before><commit_msg>100% coverage.<commit_after><|endoftext|>


<commit_before>var fs = require('fs');
var path = require('path');

var test = require('tape');
var streamStats = require('stream-stats');
var isStream = require('isstream');
var ignore = require('ignore');

var checkUsage = require('../lib/checkUsage');
var ogrChild = require('../lib/ogrChild');
var splitOGRJSON = require('../lib/splitOGRJSON');
var makeBulkSeparator = require('../lib/makeBulkSeparator');
var formatAddress = require('../lib/formatAddress');
var esLoader = require('../lib/esLoader');
var transformerTemplate = require('../lib/transformerTemplate');

test('Check Usage', function(t){
  t.plan(6);

  var program = {
    data: 'someshape',
    host: 'localhost',
    port: 9200,
    transformer: './transformers/default'
  }

  var first = checkUsage(program)
  t.equal(first.messages.length, 3);
  t.equal(first.err, 0);

  var second = checkUsage({port:9201});
  t.equal(second.messages.length, 1);
  t.equal(second.err, 1);

  var third = checkUsage({port:NaN})
  t.equal(third.messages.length, 2);
  t.equal(third.err, 1);
});

test('ogriChild module', function(t){
  t.plan(3);

  var shp = 'test/data/t.shp';
  var child = ogrChild(shp);
  var errInChild = 0;

  t.ok(child, 'ogrChild process is created');
  t.ok(isStream(child.stdout), 'the child process has stdout');

  child.stderr.once('data',function(){
    errInChild = 1;
  });

  child.stderr.once('end',function(){
    t.notOk(errInChild, 'ogr2ogr doesn\'t emit an error');
  });
});

test('splitOGRJSON module', function(t){
  t.plan(1);

  var json = 'test/data/t.json';
  var stats = streamStats('splitOGR',{store:1});

  fs.createReadStream(json)
    .pipe(splitOGRJSON())
    .pipe(stats)
    .sink();

  stats.on('end', function(){
    var result = stats.getResult();
    var validJSON = 1;
    result.chunks.forEach(function(v){
      try{
        JSON.parse(v.chunk.toString())
      }catch(e){
        validJSON = 0;
      }
    });
    t.ok(validJSON, 'splitOGRJSON yields valid JSON chunks');
  })
});

test('makeBulkSeparator module', function(t){
  t.plan(3);
  var sep = makeBulkSeparator('ind','typ');
  var sepObj = JSON.parse(sep.slice(0,sep.length-1));
  var expectedSep = {index:{_index:'ind',_type:'typ'}}
  t.deepEqual(sepObj, expectedSep, 'Bulk separator on standard input');

  var mtSep = makeBulkSeparator();
  var mtObj = JSON.parse(mtSep.slice(0,mtSep.length-1));
  var expectedMT = {index:{}};
  t.deepEqual(mtObj, expectedMT, 'Bulk separator on empty input');

  try{
    makeBulkSeparator(null, 'failing');
  }catch(e){
    t.pass('Bulk separator with a type and no index fails');
  }
});

test('formatAddress module', function(t){
  t.plan(2);

  var add1 = '123 fake st. San Francisco, CA, 12345';
  var add2 = '221B Baker St. Arg, AZ, 67876';

  t.equal(formatAddress('123 fake st.', 'San Francisco', 'CA', 12345), add1, 'Standard format')
  t.equal(formatAddress('  221B Baker St.', 'Arg  ', 'AZ', '67876'), add2, 'Trim strings');
});

test('esLoader module', function(t){
  t.plan(2);
  try{
    esLoader.connect();
  }catch(e){
    t.pass('Connect fails without host/port')
  }
  t.ok(isStream.isWritable(esLoader.load()),'esLoader.load returns a write stream');
});

test('transformerTemplate module', function(t){
  t.plan(5);
  var trans = transformerTemplate('addr','cty','st', 'zip');

  t.equal(typeof trans, 'function', 'template returns a function');
  t.ok(isStream.isDuplex(trans()), 'The produced transformer generates a transform stream');

  var stats = streamStats('transTemplate',{store:1});

  var preSufTest = trans('start','finish');

  preSufTest.pipe(stats).sink();
  stats.on('end',function(){
    var result = stats.getResult();
    var output = result.store.toString();
    t.ok(/^start/.test(output), 'prefix applied properly');
    t.ok(/finish$/.test(output), 'suffix applied properly');
  });
  preSufTest.end('{"properties":{"addr":"123 a st","cty":"sunny","st":"ca","zip":54321},"geometry":{"coordinates":[]}}')

  try{
    transformerTemplate();
  }catch(e){
    t.pass('Calling the template without all arguments throws an error');
  }
});

test('Transformers', function(t){

  fs.readdir('transformers/',function(err,transformers){

    var fieldtest = 'test/data/fieldtest.json';
    var bulkMatch = {index:{_index:'address',_type:'point'}}
    var dataMatch = {"address":"123 a st sunny, ca, 54321", "coordinates":[-129.1,38.2]};

    var bulkMetadata =  makeBulkSeparator('address', 'point');
    var filtered = ignore().addIgnoreFile('.gitignore').filter(transformers);

    t.plan(filtered.length*2);

    filtered.forEach(function(transFile){
      var transformer = require(path.join('../transformers', transFile));
      var stats = streamStats(transFile, {store:1});

      fs.createReadStream(fieldtest)
        .pipe(splitOGRJSON())
        .pipe(transformer(bulkMetadata, '\n'))
        .pipe(stats)
        .sink();

      stats.once('end', function(){
        var result = stats.getResult();
        var output = result.store.toString().split('\n')

        var bulkMeta = JSON.parse(output[0]);
        var data = JSON.parse(output[1]);

        t.deepEqual(bulkMatch, bulkMeta, "Bulk metadata created properly");
        t.deepEqual(dataMatch, data, "Data to insert transformed correctly for " + transFile);

      });
    });

  });

});
<commit_msg>Tests updated for schema/formatting changes<commit_after>var fs = require('fs');
var path = require('path');

var test = require('tape');
var streamStats = require('stream-stats');
var isStream = require('isstream');
var ignore = require('ignore');

var checkUsage = require('../lib/checkUsage');
var ogrChild = require('../lib/ogrChild');
var splitOGRJSON = require('../lib/splitOGRJSON');
var makeBulkSeparator = require('../lib/makeBulkSeparator');
var formatAddress = require('../lib/formatAddress');
var esLoader = require('../lib/esLoader');
var transformerTemplate = require('../lib/transformerTemplate');

test('Check Usage', function(t){
  t.plan(6);

  var program = {
    data: 'someshape',
    host: 'localhost',
    port: 9200,
    transformer: './transformers/default'
  }

  var first = checkUsage(program)
  t.equal(first.messages.length, 3);
  t.equal(first.err, 0);

  var second = checkUsage({port:9201});
  t.equal(second.messages.length, 1);
  t.equal(second.err, 1);

  var third = checkUsage({port:NaN})
  t.equal(third.messages.length, 2);
  t.equal(third.err, 1);
});

test('ogriChild module', function(t){
  t.plan(3);

  var shp = 'test/data/t.shp';
  var child = ogrChild(shp);
  var errInChild = 0;

  t.ok(child, 'ogrChild process is created');
  t.ok(isStream(child.stdout), 'the child process has stdout');

  child.stderr.once('data',function(){
    errInChild = 1;
  });

  child.stderr.once('end',function(){
    t.notOk(errInChild, 'ogr2ogr doesn\'t emit an error');
  });
});

test('splitOGRJSON module', function(t){
  t.plan(1);

  var json = 'test/data/t.json';
  var stats = streamStats('splitOGR',{store:1});

  fs.createReadStream(json)
    .pipe(splitOGRJSON())
    .pipe(stats)
    .sink();

  stats.on('end', function(){
    var result = stats.getResult();
    var validJSON = 1;
    result.chunks.forEach(function(v){
      try{
        JSON.parse(v.chunk.toString())
      }catch(e){
        validJSON = 0;
      }
    });
    t.ok(validJSON, 'splitOGRJSON yields valid JSON chunks');
  })
});

test('makeBulkSeparator module', function(t){
  t.plan(3);
  var sep = makeBulkSeparator('ind','typ');
  var sepObj = JSON.parse(sep.slice(0,sep.length-1));
  var expectedSep = {index:{_index:'ind',_type:'typ'}}
  t.deepEqual(sepObj, expectedSep, 'Bulk separator on standard input');

  var mtSep = makeBulkSeparator();
  var mtObj = JSON.parse(mtSep.slice(0,mtSep.length-1));
  var expectedMT = {index:{}};
  t.deepEqual(mtObj, expectedMT, 'Bulk separator on empty input');

  try{
    makeBulkSeparator(null, 'failing');
  }catch(e){
    t.pass('Bulk separator with a type and no index fails');
  }
});

test('formatAddress module', function(t){
  t.plan(2);

  var add1 = '123 fake st. San Francisco CA 12345';
  var add2 = '221B Baker St. Arg AZ 67876';

  t.equal(formatAddress('123 fake st.', 'San Francisco', 'CA', 12345), add1, 'Standard format')
  t.equal(formatAddress('  221B Baker St.', 'Arg  ', 'AZ', '67876'), add2, 'Trim strings');
});

test('esLoader module', function(t){
  t.plan(2);
  try{
    esLoader.connect();
  }catch(e){
    t.pass('Connect fails without host/port')
  }
  t.ok(isStream.isWritable(esLoader.load()),'esLoader.load returns a write stream');
});

test('transformerTemplate module', function(t){
  t.plan(5);
  var trans = transformerTemplate('addr','cty','st', 'zip');

  t.equal(typeof trans, 'function', 'template returns a function');
  t.ok(isStream.isDuplex(trans()), 'The produced transformer generates a transform stream');

  var stats = streamStats('transTemplate',{store:1});

  var preSufTest = trans('start','finish');

  preSufTest.pipe(stats).sink();
  stats.on('end',function(){
    var result = stats.getResult();
    var output = result.store.toString();
    t.ok(/^start/.test(output), 'prefix applied properly');
    t.ok(/finish$/.test(output), 'suffix applied properly');
  });
  preSufTest.end('{"properties":{"addr":"123 a st","cty":"sunny","st":"ca","zip":54321},"geometry":{"coordinates":[]}}')

  try{
    transformerTemplate();
  }catch(e){
    t.pass('Calling the template without all arguments throws an error');
  }
});

test('Transformers', function(t){

  fs.readdir('transformers/',function(err,transformers){

    var fieldtest = 'test/data/fieldtest.json';
    var bulkMatch = {index:{_index:'address',_type:'point'}}
    var dataMatch = {
      "type": "Feature",
      "properties": {
        "address": "123 a st sunny ca 54321",
        "alt_address": "",
        "load_date": 1234567890123
       },
       "geometry": {
         "type": "Point",
         "coordinates": [-129.1,38.2]
      }
    };

    var bulkMetadata =  makeBulkSeparator('address', 'point');
    var filtered = ignore().addIgnoreFile('.gitignore').filter(transformers);

    t.plan(filtered.length*3);

    filtered.forEach(function(transFile){
      var transformer = require(path.join('../transformers', transFile));
      var stats = streamStats(transFile, {store:1});

      fs.createReadStream(fieldtest)
        .pipe(splitOGRJSON())
        .pipe(transformer(bulkMetadata, '\n'))
        .pipe(stats)
        .sink();

      stats.once('end', function(){
        var result = stats.getResult();
        var output = result.store.toString().split('\n')

        var bulkMeta = JSON.parse(output[0]);
        var data = JSON.parse(output[1]);

        t.deepEqual(bulkMatch, bulkMeta, "Bulk metadata created properly");
        t.equal(dataMatch.properties.address, data.properties.address, "Address formed correctly for " + transFile);
        t.deepEqual(dataMatch.geometry, data.geometry, "Data to insert transformed correctly for " + transFile);

      });
    });

  });

});
<|endoftext|>


<commit_before>mapkob = Object.create(null);

/**
 * Generic function to prepare input for consumption
 *
 * Type can be one of:
 *  - "plain text": A regular text, sentences are delimited by periods
 *  - "newline delim": Take a string where sentences are delimited by newlines
 *  - "sentence array": Takes an array of sentences.
 *
 * @param {Object} data The input data
 * @param {String} type The type of input
 * @return {Array} An array of strings, sentences delimited by undefined
 */
mapkob.prepareInput = function(data, type) {
  function splitSentenceArray(a) {
    var delimited = [];
    a.map(function(sentence, i) {
      delimited.push(sentence.trim());
      if (i < sentences.length - 1) {
        delimited.push(undefined);
      }
    });
    return delimited;
  }

  function flattenSentenceArray(a) {
    var wordSplitRe = new RegExp("[ .]+");
    return a.map(function(sentence) {
      return sentence === undefined ? [undefined] : sentence.split(wordSplitRe);
    }).reduce(function(x,y) {return x.concat(y);});
  }
  // plain text
  var plainTextSplitter = new RegExp("([\.!?]+)", "gm")
  //var plainTextSplitter = new RegExp("(\.)")
  if (type === "plain text") {
    data = data.replace(plainTextSplitter, "\n")
    type = "newline delim"
  }

  // newline delim
  var splitRe = new RegExp("[\n\r]+", "gm");
  if (type === "newline delim") {
    var sentences = data.split(splitRe);
    var delimited = splitSentenceArray(sentences);
    return flattenSentenceArray(delimited);

  }

  // sentence array
  if (type === "sentence array") {
    var delimited = splitSentenceArray(sentences);
    return flattenSentenceArray(delimited);
  }
  return;
};

/**
 * Creates and empty Transition matrix
 *
 * @param {Number} n An integer specifying which type of n-gram to use
 * @return {Object} A Transition Matrix object
 */
mapkob.TransitionMatrix = function(n) {
  if (n % 1 !== 0 || n < 2) {throw "n needs to be an integer >= 2";}
  var uniqueWords = [];
  var matrix = {};
  var starts = {};

  this.stateSpace = [];
  this.matrix = {};
  this.initialStates = new mapkob.Row();
  this.n = n;
  return this;
};

/**
 * functional wrapper around constructor
 * Can train supplied data implicitly or load a JSONified Transition matrix.
 *
 * @param {Number} n An integer specifying which type of n-gram to use
 * @param {Object} input transition matrix input or a JSONified Matrix
 * @return {Object} A Transition Matrix
 */
mapkob.transitionMatrix = function(n, input) {
  n = n || 2;
  var output =  new mapkob.TransitionMatrix(n);

  try {
    data = JSON.parse(input);
    if (data.hasOwnProperty("type") && data.type === "mapkob Transition Matrix") {
      output.statceSpace = data.initialStates;
      output.matrix = data.matrix;
      output.initialStates = new mapkob.Row(data.initialStates.row);
    }
  } catch(err) {
    if (input !== undefined) {
      output.train(input);
    }
  }
  return output;
};

/**
 * Adds training data to an existing model
 *
 * @param {Array} words An array of consecutive words. delimited by undefined
 * @return {this} The trained model
 */
mapkob.TransitionMatrix.prototype.train = function(words) {
  function wordJoin(words, i, n) {
    var output = [];
    var offset = 1;
    while (n >= offset) {
      output.push(words[i + offset]);
      offset += 1;
    }

    return output
        .reduce(function(x,y) {return x + " " + y;})
        .replace(/undefined[\w, ]+/, "undefined");
  }

  // State space
  words.map(function(word, i) {
    if (this.stateSpace.indexOf(word) === -1) {
      this.stateSpace.push(word);
    }

    // Initial states
    if (words[i - 1] === undefined &&
        this.initialStates.row[word] === undefined) {
      this.initialStates.row[word] = 1;
      this.initialStates.stateSpace.push(word);
    } else if (words[i - 1] === undefined){
      this.initialStates.row[word] += 1;
    }

    // Rows
    if (this.matrix[word] === undefined) {
      this.matrix[word] = {};
    }
    var nextWord = wordJoin(words, i, this.n - 1);
    // Columns
    if (this.matrix[word][nextWord] === undefined) {
      this.matrix[word][nextWord] = 1;
    } else {
      this.matrix[word][nextWord] += 1;
    }
  }, this);
  return this;
};

/**
 * return the row of a matrix
 *
 * @param {String} row The row by name to look up
 * @return {Object} The row of the matrix
 */
mapkob.TransitionMatrix.prototype.getRow = function(row) {
  var output = new mapkob.Row(this.matrix[row]);
  return output;
};

/**
 * Generates a Markov chain
 *
 * @return {String} A Computer generated string
 */
mapkob.TransitionMatrix.prototype.generateChain = function() {
  var currentState = this.
    initialStates.
    probabilities().
    cumSum().
    pickState(Math.random());

  var output = [];
  while (currentState !== "undefined" && currentState !== undefined) {
    output.push(currentState);
    currentNGram = currentState.split(" ")
    currentState = currentNGram[currentNGram.length - 1];
    currentState = this.
      getRow(currentState).
      probabilities().
      cumSum().
      pickState(Math.random());
  }
  return output.join(" ") + ".";
};

/**
 * Transforms a Transitionmatrix into an identifiable object
 *
 * @return {Object} A JSON file
 */
mapkob.TransitionMatrix.prototype.toJSON = function() {
  return JSON.stringify({
    type: "mapkob Transition Matrix",
    matrix: this.matrix,
    stateSpace: this.stateSpace,
    initialStates: this.initialStates
  });
};

/**
 * A Row mapkob row constructor
 *
 * @param {Object} input A simple object
 * @return {Object} A maokob row
 */
mapkob.Row = function(input) {
  if (input === undefined) {
    this.row = {};
    this.stateSpace = [];
  } else {
    this.row = input;
    this.stateSpace = Object.keys(input);
  }
  return this;
};

/**
 * Calculates the sum of the rows
 *
 * @return {Number} The sum of the values
 */
mapkob.Row.prototype.sum = function() {
  return this.stateSpace.map(function(state) {
    return this.row[state];
  }, this).reduce(function(x, y) {
    return x + y;
  });
};

/**
 * Calculates relative frequencies of a row
 *
 * @return {Object} A row
 */
mapkob.Row.prototype.probabilities = function() {
  var sum = this.sum();
  var probs = {};
  this.stateSpace.map(function(state) {
    probs[state] = this.row[state] / sum;
  }, this);
  return new mapkob.Row(probs);
};

/**
 * A row with the cumulative sums
 *
 * @return {Object} A row
 */
mapkob.Row.prototype.cumSum = function() {
  var sums = {};
  var sum = 0;
  this.stateSpace.map(function(state) {
    sum += this.row[state];
    sums[state] = sum;
  }, this);
  return new mapkob.Row(sums);
};

/**
 * return an array with the row's values
 *
 * @return {Array} The rows values
 */
mapkob.Row.prototype.values = function() {
  return this.stateSpace.map(function(state) {
    return this.row[state];
  }, this);
};

/**
 * Picks the state with the largest CDF that is smaller or equal to p
 * Technically the first one where the next is larger or the array ends
 *
 * @return {String} A state string
 */
mapkob.Row.prototype.pickState = function(p) {
  cdf = this.values();
  for (var col in cdf) {
    if (p <= cdf[col] && (cdf[col + 1] == undefined || cdf[col + 1] > p)) {
      return this.stateSpace[col];
    }
  }
};
<commit_msg>Fixed bug that broke sum<commit_after>mapkob = Object.create(null);

/**
 * Generic function to prepare input for consumption
 *
 * Type can be one of:
 *  - "plain text": A regular text, sentences are delimited by periods
 *  - "newline delim": Take a string where sentences are delimited by newlines
 *  - "sentence array": Takes an array of sentences.
 *
 * @param {Object} data The input data
 * @param {String} type The type of input
 * @return {Array} An array of strings, sentences delimited by undefined
 */
mapkob.prepareInput = function(data, type) {
  function splitSentenceArray(a) {
    var delimited = [];
    a.map(function(sentence, i) {
      delimited.push(sentence.trim());
      if (i < sentences.length - 1) {
        delimited.push(undefined);
      }
    });
    return delimited;
  }

  function flattenSentenceArray(a) {
    var wordSplitRe = new RegExp("[ .]+");
    return a.map(function(sentence) {
      return sentence === undefined ? [undefined] : sentence.split(wordSplitRe);
    }).reduce(function(x,y) {return x.concat(y);});
  }
  // plain text
  var plainTextSplitter = new RegExp("([\.!?]+)", "gm")
  //var plainTextSplitter = new RegExp("(\.)")
  if (type === "plain text") {
    data = data.replace(plainTextSplitter, "\n")
    type = "newline delim"
  }

  // newline delim
  var splitRe = new RegExp("[\n\r]+", "gm");
  if (type === "newline delim") {
    var sentences = data.split(splitRe);
    var delimited = splitSentenceArray(sentences);
    return flattenSentenceArray(delimited);

  }

  // sentence array
  if (type === "sentence array") {
    var delimited = splitSentenceArray(sentences);
    return flattenSentenceArray(delimited);
  }
  return;
};

/**
 * Creates and empty Transition matrix
 *
 * @param {Number} n An integer specifying which type of n-gram to use
 * @return {Object} A Transition Matrix object
 */
mapkob.TransitionMatrix = function(n) {
  if (n % 1 !== 0 || n < 2) {throw "n needs to be an integer >= 2";}
  var uniqueWords = [];
  var matrix = {};
  var starts = {};

  this.stateSpace = [];
  this.matrix = {};
  this.initialStates = new mapkob.Row();
  this.n = n;
  return this;
};

/**
 * functional wrapper around constructor
 * Can train supplied data implicitly or load a JSONified Transition matrix.
 *
 * @param {Number} n An integer specifying which type of n-gram to use
 * @param {Object} input transition matrix input or a JSONified Matrix
 * @return {Object} A Transition Matrix
 */
mapkob.transitionMatrix = function(n, input) {
  n = n || 2;
  var output =  new mapkob.TransitionMatrix(n);

  try {
    data = JSON.parse(input);
    if (data.hasOwnProperty("type") && data.type === "mapkob Transition Matrix") {
      output.statceSpace = data.initialStates;
      output.matrix = data.matrix;
      output.initialStates = new mapkob.Row(data.initialStates.row);
    }
  } catch(err) {
    if (input !== undefined) {
      output.train(input);
    }
  }
  return output;
};

/**
 * Adds training data to an existing model
 *
 * @param {Array} words An array of consecutive words. delimited by undefined
 * @return {this} The trained model
 */
mapkob.TransitionMatrix.prototype.train = function(words) {
  function wordJoin(words, i, n) {
    var output = [];
    var offset = 1;
    while (n >= offset) {
      output.push(words[i + offset]);
      offset += 1;
    }

    return output
        .reduce(function(x,y) {return x + " " + y;})
        .replace(/undefined[\w, ]+/, "undefined");
  }

  // State space
  words.map(function(word, i) {
    if (this.stateSpace.indexOf(word) === -1) {
      this.stateSpace.push(word);
    }

    // Initial states
    if (words[i - 1] === undefined &&
        this.initialStates.row[word] === undefined) {
      this.initialStates.row[word] = 1;
      this.initialStates.stateSpace.push(word);
    } else if (words[i - 1] === undefined){
      this.initialStates.row[word] += 1;
    }

    // Rows
    if (this.matrix[word] === undefined) {
      this.matrix[word] = {};
    }
    var nextWord = wordJoin(words, i, this.n - 1);
    // Columns
    if (this.matrix[word][nextWord] === undefined) {
      this.matrix[word][nextWord] = 1;
    } else {
      this.matrix[word][nextWord] += 1;
    }
  }, this);
  return this;
};

/**
 * return the row of a matrix
 *
 * @param {String} row The row by name to look up
 * @return {Object} The row of the matrix
 */
mapkob.TransitionMatrix.prototype.getRow = function(row) {
  var output = new mapkob.Row(this.matrix[row]);
  return output;
};

/**
 * Generates a Markov chain
 *
 * @return {String} A Computer generated string
 */
mapkob.TransitionMatrix.prototype.generateChain = function() {
  var currentState = this.
    initialStates.
    probabilities().
    cumSum().
    pickState(Math.random());
  var output = [];
  while (true) {
    output.push(currentState);
    currentNGram = currentState.split(" ");
    currentState = currentNGram[currentNGram.length - 1];
    if (currentState === "undefined") {break;}
    currentState = this.
      getRow(currentState).
      probabilities().
      cumSum().
      pickState(Math.random());
  }
  return output.join(" ") + ".";
};

/**
 * Transforms a Transitionmatrix into an identifiable object
 *
 * @return {Object} A JSON file
 */
mapkob.TransitionMatrix.prototype.toJSON = function() {
  return JSON.stringify({
    type: "mapkob Transition Matrix",
    matrix: this.matrix,
    stateSpace: this.stateSpace,
    initialStates: this.initialStates
  });
};

/**
 * A Row mapkob row constructor
 *
 * @param {Object} input A simple object
 * @return {Object} A maokob row
 */
mapkob.Row = function(input) {
  if (input === undefined) {
    this.row = {};
    this.stateSpace = [];
  } else {
    this.row = input;
    this.stateSpace = Object.keys(input);
  }
  return this;
};

/**
 * Calculates the sum of the rows
 *
 * @return {Number} The sum of the values
 */
mapkob.Row.prototype.sum = function() {
  return this.stateSpace.map(function(state) {
    return this.row[state];
  }, this).reduce(function(x, y) {
    return x + y;
  });
};

/**
 * Calculates relative frequencies of a row
 *
 * @return {Object} A row
 */
mapkob.Row.prototype.probabilities = function() {
  var sum = this.sum();
  var probs = {};
  this.stateSpace.map(function(state) {
    probs[state] = this.row[state] / sum;
  }, this);
  return new mapkob.Row(probs);
};

/**
 * A row with the cumulative sums
 *
 * @return {Object} A row
 */
mapkob.Row.prototype.cumSum = function() {
  var sums = {};
  var sum = 0;
  this.stateSpace.map(function(state) {
    sum += this.row[state];
    sums[state] = sum;
  }, this);
  return new mapkob.Row(sums);
};

/**
 * return an array with the row's values
 *
 * @return {Array} The rows values
 */
mapkob.Row.prototype.values = function() {
  return this.stateSpace.map(function(state) {
    return this.row[state];
  }, this);
};

/**
 * Picks the state with the largest CDF that is smaller or equal to p
 * Technically the first one where the next is larger or the array ends
 *
 * @return {String} A state string
 */
mapkob.Row.prototype.pickState = function(p) {
  cdf = this.values();
  for (var col in cdf) {
    if (p <= cdf[col] && (cdf[col + 1] == undefined || cdf[col + 1] > p)) {
      return this.stateSpace[col];
    }
  }
};
<|endoftext|>


<commit_before>'use strict';

var binCheck = require('bin-check');
var BinBuild = require('bin-build');
var execFile = require('child_process').execFile;
var fs = require('fs');
var mkdir = require('mkdirp');
var path = require('path');
var rm = require('rimraf');
var test = require('ava');
var tmp = path.join(__dirname, 'tmp');

test('rebuild the mozjpeg binaries', function (t) {
	t.plan(3);

	var builder = new BinBuild()
		.src('https://github.com/mozilla/mozjpeg/archive/v2.1.tar.gz')
		.cmd('autoreconf -fiv && ./configure --prefix="' + tmp + '" --bindir="' + tmp + '" --libdir="' + tmp + '"')
		.cmd('make && make install');

	builder.build(function (err) {
		t.assert(!err);

		fs.exists(path.join(tmp, 'jpegtran'), function (exists) {
			t.assert(exists);

			rm(tmp, function (err) {
				t.assert(!err);
			});
		});
	});
});

test('return path to binary and verify that it is working', function (t) {
	t.plan(3);

	var args = [
		'-outfile', path.join(tmp, 'test.jpg'),
		path.join(__dirname, 'fixtures/test.jpg')
	];

	mkdir(tmp, function (err) {
		t.assert(!err);

		binCheck(require('../').path, args, function (err, works) {
			t.assert(!err);
			t.assert(works);

		});
	});
});

test('minify a JPG', function (t) {
	t.plan(6);

	var args = [
		'-outfile', path.join(tmp, 'test.jpg'),
		path.join(__dirname, 'fixtures/test.jpg')
	];

	mkdir(tmp, function (err) {
		t.assert(!err);

		execFile(require('../').path, args, function (err) {
			t.assert(!err);

			fs.stat(path.join(__dirname, 'fixtures/test.jpg'), function (err, a) {
				t.assert(!err);

				fs.stat(path.join(tmp, 'test.jpg'), function (err, b) {
					t.assert(!err);
					t.assert(b.size < a.size);

					rm(tmp, function (err) {
						t.assert(!err);
					});
				});
			});
		});
	});
});
<commit_msg>Minor tweak<commit_after>'use strict';

var binCheck = require('bin-check');
var BinBuild = require('bin-build');
var execFile = require('child_process').execFile;
var fs = require('fs');
var mkdir = require('mkdirp');
var path = require('path');
var rm = require('rimraf');
var test = require('ava');
var tmp = path.join(__dirname, 'tmp');

test('rebuild the mozjpeg binaries', function (t) {
	t.plan(3);

	var builder = new BinBuild()
		.src('https://github.com/mozilla/mozjpeg/archive/v2.1.tar.gz')
		.cmd('autoreconf -fiv && ./configure --prefix="' + tmp + '" --bindir="' + tmp + '" --libdir="' + tmp + '"')
		.cmd('make && make install');

	builder.build(function (err) {
		t.assert(!err);

		fs.exists(path.join(tmp, 'jpegtran'), function (exists) {
			t.assert(exists);

			rm(tmp, function (err) {
				t.assert(!err);
			});
		});
	});
});

test('return path to binary and verify that it is working', function (t) {
	t.plan(3);

	var args = [
		'-outfile', path.join(tmp, 'test.jpg'),
		path.join(__dirname, 'fixtures/test.jpg')
	];

	mkdir(tmp, function (err) {
		t.assert(!err);

		binCheck(require('../').path, args, function (err, works) {
			t.assert(!err);
			t.assert(works);
		});
	});
});

test('minify a JPG', function (t) {
	t.plan(6);

	var args = [
		'-outfile', path.join(tmp, 'test.jpg'),
		path.join(__dirname, 'fixtures/test.jpg')
	];

	mkdir(tmp, function (err) {
		t.assert(!err);

		execFile(require('../').path, args, function (err) {
			t.assert(!err);

			fs.stat(path.join(__dirname, 'fixtures/test.jpg'), function (err, a) {
				t.assert(!err);

				fs.stat(path.join(tmp, 'test.jpg'), function (err, b) {
					t.assert(!err);
					t.assert(b.size < a.size);

					rm(tmp, function (err) {
						t.assert(!err);
					});
				});
			});
		});
	});
});
<|endoftext|>


<commit_before>/**
 * Tput for node.js
 * Copyright (c) 2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/blessed
 */

// Compile xterm terminfo/termcap:
// $ tic -a -I -1 usr/xterm.terminfo
// $ tic -a -C -U usr/xterm.termcap

// Compile xterm terminfo/termcap:
// $ tic -a -1 usr/xterm.terminfo
// $ tic -a -1 usr/xterm.terminfo && ls ~/.terminfo
// $ tic -a -1 -o usr usr/xterm.terminfo && mv usr/x/xterm usr/ && rm -rf usr/v usr/x
// $ tic -a -1 -o usr usr/xterm.terminfo && mv usr/x/xterm-256color usr/ && rm -rf usr/v usr/x

// Check tput output:
// $ node test/tput.js xterm | tee out
// $ node test/tput.js xterm --ifile usr/xterm | tee out
// $ node test/tput.js xterm-256color --ifile usr/xterm-256color | tee out
// $ node test/tput.js vt102 --termcap | tee out
// $ node test/tput.js xterm --termcap --cfile usr/xterm.termcap | tee out
// $ node test/tput.js xterm --iprefix ~/.terminfo | tee out
// $ node test/tput.js xterm-256color --ifile ~/.terminfo/x/xterm-256color | tee out
// $ cdiff test/terminfo out

var blessed = require('../');

// Simple argument parser
// Copyright (c) 2012, Christopher Jeffrey (MIT License)

function parseArg() {
  var argv = process.argv.slice(2)
    , options = [];

  function getarg() {
    var arg = argv.shift();

    if (arg.indexOf('--') === 0) {
      // e.g. --opt
      arg = arg.split('=');
      if (arg.length > 1) {
        // e.g. --opt=val
        argv.unshift(arg.slice(1).join('='));
      }
      arg = arg[0];
    } else if (arg[0] === '-') {
      if (arg.length > 2) {
        // e.g. -abc
        argv = arg.substring(1).split('').map(function(ch) {
          return '-' + ch;
        }).concat(argv);
        arg = argv.shift();
      } else {
        // e.g. -a
      }
    } else {
      // e.g. foo
    }

    return arg;
  }

  while (argv.length) {
    arg = getarg();
    if (arg.indexOf('-') === 0) {
      arg = arg.replace(/^--?/, '');
      if (argv[0] && argv[0].indexOf('-') !== 0) {
        options[arg] = argv.shift();
      } else {
        options[arg] = true;
      }
    } else {
      options.push(arg);
    }
  }

  return options;
}

var argv = parseArg();

var tput = blessed.tput({
  term: argv[0] !== 'all' && argv[0] !== 'rand'
    ? argv[0] || __dirname + '/../usr/xterm'
    : null,
  extended: true,
  debug: true,
  termcap: argv.termcap,
  terminfoFile: argv.i || argv.ifile,
  terminfoPrefix: argv.p || argv.iprefix,
  termcapFile: argv.c || argv.cfile
});

if (argv[0] === 'all') {
  var rl = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

  var text = '\x1b[31mWARNING:\x1b[m '
    + 'This will compile every single terminfo file on your disk.\n'
    + 'It will probably use a lot of CPU.\n'
    + 'Do you wish to proceed? (Y/n) ';

  rl.question(text, function(result) {
    result = result.trim().toLowerCase();
    if (result !== 'y') return process.exit(0);
    console.log('\x1b[32m(You bet your ass I wish to proceed.)\x1b[m');
    tput._write('$<1000/>.$<1000/>.$<1000/>.$<100/>Let\'s go...', process.stdout.write.bind(process.stdout), function() {
    });
    setTimeout(function() { process.stdout.write('.'); }, 1000);
    setTimeout(function() { process.stdout.write('.'); }, 2000);
    setTimeout(function() { process.stdout.write('.'); }, 3000);
    setTimeout(function() {
      console.log('Let\'s go...');
    }, 3100);
    setTimeout(function() {
      tput.compileAll(argv[1]);
      process.exit(0);
    }, 4000);
  });

  return;
}

if (argv[0] === 'rand') {
  var terms = tput.getAll()
    , term;

  term = terms[(terms.length - 1) * Math.random() | 0];

  console.log('Compiling ' + term + '...');
  tput.compileTerminfo(term);
  console.log('Compiled ' + term + '.');

  return;
}

// console.log('Max colors: %d.', tput.colors);

// console.log(tput.strings.acs_chars.split('').map(function(ch) { return ch.charCodeAt(0); }));
// console.log(JSON.stringify(tput.strings.acs_chars));

// process.stdout.write(blessed.tput.sprintf('%-10s\n', 'hello'));

// tput._compile({ name: 'xterm' }, 'set_attributes',
//   '%?%p9%t\u001b(0%e\u001b(B%;\u001b[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m');

// console.log(tput.setaf(4) + 'foo' + tput.sgr0());
// console.log(tput.setaf(4) + 'foo' + tput.sgr(0));

// tput.padding = true;
// tput._print('hello$<1000/>world', console.log, function() {
//   tput._print('$<1000/>foo$<1000/>bar', console.log, process.exit);
// });
<commit_msg>minor test change.<commit_after>/**
 * Tput for node.js
 * Copyright (c) 2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/blessed
 */

// Compile xterm terminfo/termcap:
// $ tic -a -I -1 usr/xterm.terminfo
// $ tic -a -C -U usr/xterm.termcap

// Compile xterm terminfo/termcap:
// $ tic -a -1 usr/xterm.terminfo
// $ tic -a -1 usr/xterm.terminfo && ls ~/.terminfo
// $ tic -a -1 -o usr usr/xterm.terminfo && mv usr/x/xterm usr/ && rm -rf usr/v usr/x
// $ tic -a -1 -o usr usr/xterm.terminfo && mv usr/x/xterm-256color usr/ && rm -rf usr/v usr/x

// Check tput output:
// $ node test/tput.js xterm | tee out
// $ node test/tput.js xterm --ifile usr/xterm | tee out
// $ node test/tput.js xterm-256color --ifile usr/xterm-256color | tee out
// $ node test/tput.js vt102 --termcap | tee out
// $ node test/tput.js xterm --termcap --cfile usr/xterm.termcap | tee out
// $ node test/tput.js xterm --iprefix ~/.terminfo | tee out
// $ node test/tput.js xterm-256color --ifile ~/.terminfo/x/xterm-256color | tee out
// $ cdiff test/terminfo out

var blessed = require('../');

// Simple argument parser
// Copyright (c) 2012, Christopher Jeffrey (MIT License)

function parseArg() {
  var argv = process.argv.slice(2)
    , options = [];

  function getarg() {
    var arg = argv.shift();

    if (arg.indexOf('--') === 0) {
      // e.g. --opt
      arg = arg.split('=');
      if (arg.length > 1) {
        // e.g. --opt=val
        argv.unshift(arg.slice(1).join('='));
      }
      arg = arg[0];
    } else if (arg[0] === '-') {
      if (arg.length > 2) {
        // e.g. -abc
        argv = arg.substring(1).split('').map(function(ch) {
          return '-' + ch;
        }).concat(argv);
        arg = argv.shift();
      } else {
        // e.g. -a
      }
    } else {
      // e.g. foo
    }

    return arg;
  }

  while (argv.length) {
    arg = getarg();
    if (arg.indexOf('-') === 0) {
      arg = arg.replace(/^--?/, '');
      if (argv[0] && argv[0].indexOf('-') !== 0) {
        options[arg] = argv.shift();
      } else {
        options[arg] = true;
      }
    } else {
      options.push(arg);
    }
  }

  return options;
}

var argv = parseArg();

var tput = blessed.tput({
  term: argv[0] !== 'all' && argv[0] !== 'rand'
    ? argv[0] || __dirname + '/../usr/xterm'
    : null,
  extended: true,
  debug: true,
  termcap: argv.termcap,
  terminfoFile: argv.i || argv.ifile,
  terminfoPrefix: argv.p || argv.iprefix,
  termcapFile: argv.c || argv.cfile
});

if (argv[0] === 'all') {
  var rl = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

  var text = '\x1b[31mWARNING:\x1b[m '
    + 'This will compile every single terminfo file on your disk.\n'
    + 'It will probably use a lot of CPU.\n'
    + 'Do you wish to proceed? (Y/n) ';

  rl.question(text, function(result) {
    result = result.trim().toLowerCase();
    if (result !== 'y') return process.exit(0);
    console.log('\x1b[32m(You bet your ass I wish to proceed.)\x1b[m');
    // tput._write('$<1000/>.$<1000/>.$<1000/>.$<100/>Let\'s go...',
    //   process.stdout.write.bind(process.stdout),
    //   function() {});
    setTimeout(function() { process.stdout.write('.'); }, 1000);
    setTimeout(function() { process.stdout.write('.'); }, 2000);
    setTimeout(function() { process.stdout.write('.'); }, 3000);
    setTimeout(function() { console.log('Let\'s go...'); }, 3100);
    setTimeout(function() {
      tput.compileAll(argv[1]);
      process.exit(0);
    }, 4000);
  });

  return;
}

if (argv[0] === 'rand') {
  var terms = tput.getAll()
    , term;

  term = terms[(terms.length - 1) * Math.random() | 0];

  console.log('Compiling ' + term + '...');
  tput.compileTerminfo(term);
  console.log('Compiled ' + term + '.');

  return;
}

// console.log('Max colors: %d.', tput.colors);

// console.log(tput.strings.acs_chars.split('').map(function(ch) { return ch.charCodeAt(0); }));
// console.log(JSON.stringify(tput.strings.acs_chars));

// process.stdout.write(blessed.tput.sprintf('%-10s\n', 'hello'));

// tput._compile({ name: 'xterm' }, 'set_attributes',
//   '%?%p9%t\u001b(0%e\u001b(B%;\u001b[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m');

// console.log(tput.setaf(4) + 'foo' + tput.sgr0());
// console.log(tput.setaf(4) + 'foo' + tput.sgr(0));

// tput.padding = true;
// tput._print('hello$<1000/>world', console.log, function() {
//   tput._print('$<1000/>foo$<1000/>bar', console.log, process.exit);
// });
<|endoftext|>


<commit_before>var osmdb = require('../../')
var osm = osmdb()

document.querySelector('form#add').addEventListener('submit', onadd)
document.querySelector('form#query').addEventListener('submit', onquery)

function onadd (ev) {
  var form = this
  ev.preventDefault()
  var doc = {
    lat: this.elements.lat.value,
    lon: this.elements.lon.value
  }
  osm.create(doc, function (err, key, node) {
    if (err) console.error(err)
    else form.reset()
  })
}

function onquery (ev) {
  ev.preventDefault()
  var q = [
    [ this.elements.minlat.value, this.elements.maxlat.value ],
    [ this.elements.minlon.value, this.elements.maxlon.value ]
  ]
  osm.query(q, function (err, results) {
    document.querySelector('#query-results').innerText
      = results.map(str).join('\n')
    function str (row) { return JSON.stringify(row) }
  })
}
<commit_msg>number, still getting error<commit_after>var osmdb = require('../../')
var osm = osmdb()

document.querySelector('form#add').addEventListener('submit', onadd)
document.querySelector('form#query').addEventListener('submit', onquery)

function onadd (ev) {
  var form = this
  ev.preventDefault()
  var doc = {
    type: 'node',
    lat: Number(this.elements.lat.value),
    lon: Number(this.elements.lon.value)
  }
  osm.create(doc, function (err, key, node) {
    if (err) console.error(err)
    else form.reset()
  })
}

function onquery (ev) {
  ev.preventDefault()
  var q = [
    [ this.elements.minlat.value, this.elements.maxlat.value ],
    [ this.elements.minlon.value, this.elements.maxlon.value ]
  ]
  osm.query(q, function (err, results) {
    document.querySelector('#query-results').innerText
      = results.map(str).join('\n')
    function str (row) { return JSON.stringify(row) }
  })
}
<|endoftext|>


<commit_before>var ClientApp = require("../lib/app"),
    path = require("path");

// Set up the app

var exampleApp = new ClientApp({
    name: "Example",
    version: "0.1.0",
    hostname: "example.localhost",
    port: 80,
    views: path.join(__dirname, "views")
});

// Add another view

exampleApp.get("/about", function(req, res, next) {
    res.render("about", {title: "About"});
});

exampleApp.run(function(err) {
});
<commit_msg>remove redundant route<commit_after>var ClientApp = require("../lib/app"),
    path = require("path");

// Set up the app

var exampleApp = new ClientApp({
    name: "Example",
    version: "0.1.0",
    hostname: "example.localhost",
    port: 80,
    views: path.join(__dirname, "views")
});

exampleApp.run(function(err) {
});
<|endoftext|>


<commit_before>System.config({
  baseURL: ".",
  defaultJSExtensions: true,
  transpiler: false,
  typescriptOptions: {
    "module": "system",
    "noImplicitAny": false,
    "typeCheck": true,
    "tsconfig": true
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

  packages: {
    "src": {
      "main": "index.tsx",
      "defaultExtension": "tsx",
      "meta": {
        "*.js": {
          "loader": "ts"
        },
        "*.jsx": {
          "loader": "ts"
        },
        "*.ts": {
          "loader": "ts"
        },
        "*.tsx": {
          "loader": "ts"
        },
        "*.css": {
          "loader": "css"
        }
      }
    }
  }
});
<commit_msg>fix(example): fix react example<commit_after>System.config({
  baseURL: ".",
  defaultJSExtensions: true,
  transpiler: "typescript",
  typescriptOptions: {
    "module": "system",
    "noImplicitAny": false,
    "typeCheck": true,
    "tsconfig": true
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

  packages: {
    "src": {
      "main": "index.tsx",
      "defaultExtension": "tsx",
      "meta": {
        "*.js": {
          "loader": "ts"
        },
        "*.jsx": {
          "loader": "ts"
        },
        "*.ts": {
          "loader": "ts"
        },
        "*.tsx": {
          "loader": "ts"
        },
        "*.css": {
          "loader": "css"
        }
      }
    }
  },

  map: {
    "clean-css": "npm:clean-css@3.4.9",
    "css": "github:systemjs/plugin-css@0.1.20",
    "react": "npm:react@0.13.3",
    "systemjs-hot-reloader": "github:capaj/systemjs-hot-reloader@0.5.4",
    "ts": "github:frankwallis/plugin-typescript@2.5.0",
    "typescript": "npm:typescript@1.7.5",
    "github:capaj/systemjs-hot-reloader@0.5.4": {
      "debug": "npm:debug@2.2.0",
      "socket.io-client": "github:socketio/socket.io-client@1.4.4",
      "weakee": "npm:weakee@0.9.1"
    },
    "github:frankwallis/plugin-typescript@2.5.0": {
      "typescript": "npm:typescript@1.7.5"
    },
    "github:jspm/nodelibs-assert@0.1.0": {
      "assert": "npm:assert@1.3.0"
    },
    "github:jspm/nodelibs-buffer@0.1.0": {
      "buffer": "npm:buffer@3.6.0"
    },
    "github:jspm/nodelibs-constants@0.1.0": {
      "constants-browserify": "npm:constants-browserify@0.0.1"
    },
    "github:jspm/nodelibs-crypto@0.1.0": {
      "crypto-browserify": "npm:crypto-browserify@3.11.0"
    },
    "github:jspm/nodelibs-events@0.1.1": {
      "events": "npm:events@1.0.2"
    },
    "github:jspm/nodelibs-http@1.7.1": {
      "Base64": "npm:Base64@0.2.1",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "stream": "github:jspm/nodelibs-stream@0.1.0",
      "url": "github:jspm/nodelibs-url@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "github:jspm/nodelibs-https@0.1.0": {
      "https-browserify": "npm:https-browserify@0.0.0"
    },
    "github:jspm/nodelibs-net@0.1.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "http": "github:jspm/nodelibs-http@1.7.1",
      "net": "github:jspm/nodelibs-net@0.1.2",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "stream": "github:jspm/nodelibs-stream@0.1.0",
      "timers": "github:jspm/nodelibs-timers@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "github:jspm/nodelibs-os@0.1.0": {
      "os-browserify": "npm:os-browserify@0.1.2"
    },
    "github:jspm/nodelibs-path@0.1.0": {
      "path-browserify": "npm:path-browserify@0.0.0"
    },
    "github:jspm/nodelibs-process@0.1.2": {
      "process": "npm:process@0.11.2"
    },
    "github:jspm/nodelibs-stream@0.1.0": {
      "stream-browserify": "npm:stream-browserify@1.0.0"
    },
    "github:jspm/nodelibs-string_decoder@0.1.0": {
      "string_decoder": "npm:string_decoder@0.10.31"
    },
    "github:jspm/nodelibs-timers@0.1.0": {
      "timers-browserify": "npm:timers-browserify@1.4.2"
    },
    "github:jspm/nodelibs-tty@0.1.0": {
      "tty-browserify": "npm:tty-browserify@0.0.0"
    },
    "github:jspm/nodelibs-url@0.1.0": {
      "url": "npm:url@0.10.3"
    },
    "github:jspm/nodelibs-util@0.1.0": {
      "util": "npm:util@0.10.3"
    },
    "github:jspm/nodelibs-vm@0.1.0": {
      "vm-browserify": "npm:vm-browserify@0.0.4"
    },
    "npm:amdefine@1.0.0": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "module": "github:jspm/nodelibs-module@0.1.0",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:asn1.js@4.3.0": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "bn.js": "npm:bn.js@4.6.6",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "inherits": "npm:inherits@2.0.1",
      "minimalistic-assert": "npm:minimalistic-assert@1.0.0",
      "vm": "github:jspm/nodelibs-vm@0.1.0"
    },
    "npm:assert@1.3.0": {
      "util": "npm:util@0.10.3"
    },
    "npm:browserify-aes@1.0.6": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "buffer-xor": "npm:buffer-xor@1.0.3",
      "cipher-base": "npm:cipher-base@1.0.2",
      "create-hash": "npm:create-hash@1.1.2",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "evp_bytestokey": "npm:evp_bytestokey@1.0.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "inherits": "npm:inherits@2.0.1",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:browserify-cipher@1.0.0": {
      "browserify-aes": "npm:browserify-aes@1.0.6",
      "browserify-des": "npm:browserify-des@1.0.0",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "evp_bytestokey": "npm:evp_bytestokey@1.0.0"
    },
    "npm:browserify-des@1.0.0": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "cipher-base": "npm:cipher-base@1.0.2",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "des.js": "npm:des.js@1.0.0",
      "inherits": "npm:inherits@2.0.1"
    },
    "npm:browserify-rsa@4.0.0": {
      "bn.js": "npm:bn.js@4.6.6",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "constants": "github:jspm/nodelibs-constants@0.1.0",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "randombytes": "npm:randombytes@2.0.2"
    },
    "npm:browserify-sign@4.0.0": {
      "bn.js": "npm:bn.js@4.6.6",
      "browserify-rsa": "npm:browserify-rsa@4.0.0",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "create-hash": "npm:create-hash@1.1.2",
      "create-hmac": "npm:create-hmac@1.1.4",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "elliptic": "npm:elliptic@6.2.0",
      "inherits": "npm:inherits@2.0.1",
      "parse-asn1": "npm:parse-asn1@5.0.0",
      "stream": "github:jspm/nodelibs-stream@0.1.0"
    },
    "npm:buffer-xor@1.0.3": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:buffer@3.6.0": {
      "base64-js": "npm:base64-js@0.0.8",
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "ieee754": "npm:ieee754@1.1.6",
      "isarray": "npm:isarray@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:cipher-base@1.0.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "inherits": "npm:inherits@2.0.1",
      "stream": "github:jspm/nodelibs-stream@0.1.0",
      "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0"
    },
    "npm:clean-css@3.4.9": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "commander": "npm:commander@2.8.1",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "http": "github:jspm/nodelibs-http@1.7.1",
      "https": "github:jspm/nodelibs-https@0.1.0",
      "os": "github:jspm/nodelibs-os@0.1.0",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "source-map": "npm:source-map@0.4.4",
      "url": "github:jspm/nodelibs-url@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:commander@2.8.1": {
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "graceful-readlink": "npm:graceful-readlink@1.0.1",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:constants-browserify@0.0.1": {
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:core-util-is@1.0.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0"
    },
    "npm:create-ecdh@4.0.0": {
      "bn.js": "npm:bn.js@4.6.6",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "elliptic": "npm:elliptic@6.2.0"
    },
    "npm:create-hash@1.1.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "cipher-base": "npm:cipher-base@1.0.2",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "inherits": "npm:inherits@2.0.1",
      "ripemd160": "npm:ripemd160@1.0.1",
      "sha.js": "npm:sha.js@2.4.4"
    },
    "npm:create-hmac@1.1.4": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "create-hash": "npm:create-hash@1.1.2",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "inherits": "npm:inherits@2.0.1",
      "stream": "github:jspm/nodelibs-stream@0.1.0"
    },
    "npm:crypto-browserify@3.11.0": {
      "browserify-cipher": "npm:browserify-cipher@1.0.0",
      "browserify-sign": "npm:browserify-sign@4.0.0",
      "create-ecdh": "npm:create-ecdh@4.0.0",
      "create-hash": "npm:create-hash@1.1.2",
      "create-hmac": "npm:create-hmac@1.1.4",
      "diffie-hellman": "npm:diffie-hellman@5.0.1",
      "inherits": "npm:inherits@2.0.1",
      "pbkdf2": "npm:pbkdf2@3.0.4",
      "public-encrypt": "npm:public-encrypt@4.0.0",
      "randombytes": "npm:randombytes@2.0.2"
    },
    "npm:debug@2.2.0": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "ms": "npm:ms@0.7.1",
      "net": "github:jspm/nodelibs-net@0.1.2",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "tty": "github:jspm/nodelibs-tty@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:des.js@1.0.0": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "inherits": "npm:inherits@2.0.1",
      "minimalistic-assert": "npm:minimalistic-assert@1.0.0"
    },
    "npm:diffie-hellman@5.0.1": {
      "bn.js": "npm:bn.js@4.6.6",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "miller-rabin": "npm:miller-rabin@4.0.0",
      "randombytes": "npm:randombytes@2.0.2",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:elliptic@6.2.0": {
      "bn.js": "npm:bn.js@4.6.6",
      "brorand": "npm:brorand@1.0.5",
      "hash.js": "npm:hash.js@1.0.3",
      "inherits": "npm:inherits@2.0.1",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:envify@3.4.0": {
      "jstransform": "npm:jstransform@10.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "through": "npm:through@2.3.8"
    },
    "npm:esprima-fb@13001.1001.0-dev-harmony-fb": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:evp_bytestokey@1.0.0": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "create-hash": "npm:create-hash@1.1.2",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0"
    },
    "npm:graceful-readlink@1.0.1": {
      "fs": "github:jspm/nodelibs-fs@0.1.2"
    },
    "npm:hash.js@1.0.3": {
      "inherits": "npm:inherits@2.0.1"
    },
    "npm:https-browserify@0.0.0": {
      "http": "github:jspm/nodelibs-http@1.7.1"
    },
    "npm:inherits@2.0.1": {
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:jstransform@10.1.0": {
      "base62": "npm:base62@0.1.1",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "esprima-fb": "npm:esprima-fb@13001.1001.0-dev-harmony-fb",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "source-map": "npm:source-map@0.1.31"
    },
    "npm:miller-rabin@4.0.0": {
      "bn.js": "npm:bn.js@4.6.6",
      "brorand": "npm:brorand@1.0.5"
    },
    "npm:os-browserify@0.1.2": {
      "os": "github:jspm/nodelibs-os@0.1.0"
    },
    "npm:parse-asn1@5.0.0": {
      "asn1.js": "npm:asn1.js@4.3.0",
      "browserify-aes": "npm:browserify-aes@1.0.6",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "create-hash": "npm:create-hash@1.1.2",
      "evp_bytestokey": "npm:evp_bytestokey@1.0.0",
      "pbkdf2": "npm:pbkdf2@3.0.4",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:path-browserify@0.0.0": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:pbkdf2@3.0.4": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "create-hmac": "npm:create-hmac@1.1.4",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:process@0.11.2": {
      "assert": "github:jspm/nodelibs-assert@0.1.0"
    },
    "npm:public-encrypt@4.0.0": {
      "bn.js": "npm:bn.js@4.6.6",
      "browserify-rsa": "npm:browserify-rsa@4.0.0",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "create-hash": "npm:create-hash@1.1.2",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "parse-asn1": "npm:parse-asn1@5.0.0",
      "randombytes": "npm:randombytes@2.0.2"
    },
    "npm:punycode@1.3.2": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:randombytes@2.0.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:react@0.13.3": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "envify": "npm:envify@3.4.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:readable-stream@1.1.13": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "core-util-is": "npm:core-util-is@1.0.2",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "isarray": "npm:isarray@0.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "stream-browserify": "npm:stream-browserify@1.0.0",
      "string_decoder": "npm:string_decoder@0.10.31"
    },
    "npm:ripemd160@1.0.1": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:sha.js@2.4.4": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:source-map@0.1.31": {
      "amdefine": "npm:amdefine@1.0.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:source-map@0.4.4": {
      "amdefine": "npm:amdefine@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:stream-browserify@1.0.0": {
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "readable-stream": "npm:readable-stream@1.1.13"
    },
    "npm:string_decoder@0.10.31": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0"
    },
    "npm:through@2.3.8": {
      "process": "github:jspm/nodelibs-process@0.1.2",
      "stream": "github:jspm/nodelibs-stream@0.1.0"
    },
    "npm:timers-browserify@1.4.2": {
      "process": "npm:process@0.11.2"
    },
    "npm:url@0.10.3": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "punycode": "npm:punycode@1.3.2",
      "querystring": "npm:querystring@0.2.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:util@0.10.3": {
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:vm-browserify@0.0.4": {
      "indexof": "npm:indexof@0.0.1"
    },
    "npm:weakee@0.9.1": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    }
  }
});
<|endoftext|>