<commit_before>'use strict';
// var assert = require('assert');
var chai = require('chai');
var spies = require('chai-spies');
chai.use(spies);
// var should = chai.should();
var expect = chai.expect;
var angularWebsockets = require('./');
var WebSocket = require('ws');
var port = 8888;

var server = angularWebsockets({
    port: port
});

beforeEach(function() {
    server.close();
    server = angularWebsockets({
        port: port
    });
});

it('should connect', function(done) {
    var ws = new WebSocket('ws://localhost:' + port);
    ws.on('open', function open() {
        done();
    });
});

describe('availableEvents', function() {
    it('should have exist and be an object', function() {
        expect(typeof server.availableEvents).to.equal('object');
    });
    it('should have property \'close\' of type string', function() {
        expect(typeof server.availableEvents.close).to.equal('string');
    });
    it('should have property \'error\' of type string', function() {
        expect(typeof server.availableEvents.error).to.equal('string');
    });
    it('should have property \'unkown\' of type string', function() {
        expect(typeof server.availableEvents.unkown).to.equal('string');
    });
    it('should have property \'message\' of type string', function() {
        expect(typeof server.availableEvents.message).to.equal('string');
    });
});

describe('close', function() {
    it('should have exist and be a function', function() {
        expect(typeof server.close).to.equal('function');
    });
    it('should close the server connections', function(done) {
        var ws = new WebSocket('ws://localhost:' + port);
        ws.on('close', function() {
            done();
        });
        ws.on('open', function open() {
            server.close();
        });
    });
    it('should call on-\'server.availableEvents.close\'-listeners once when closing the server', function() {
        var spy = chai.spy();
        server.on(server.availableEvents.close, spy);
        server.close();
        expect(spy).to.be.called.once();
    });
    it('should call all on-server.availableEvents.close-listeners once when closing the server', function() {
        var spy = chai.spy();
        server.on(server.availableEvents.close, spy);
        server.on(server.availableEvents.close, spy);
        server.close();
        expect(spy).to.be.called.twice();
    });
});

describe('on', function() {
    it('should have exist and be a function', function() {
        expect(typeof server.on).to.equal('function');
    });
    it('should accept only a string and a function as argument', function() {
        expect(server.on.bind(server, 5, 'doStuff')).to.throw('Need a string as first argument and a function as second.');
        expect(server.on.bind(server, '5', 'doStuff')).to.throw('Need a string as first argument and a function as second.');
        expect(server.on.bind(server, '5', {
            test: 1
        })).to.throw('Need a string as first argument and a function as second.');
        expect(server.on.bind(server, '5', function() {})).not.to.throw();
    });
    it('should call the event-listener when event is emitted from a client', function(done) {
        var ws = new WebSocket('ws://localhost:' + port);
        server.on('myEvent', function() {
            done();
        });
        ws.on('open', function open() {
            ws.send(JSON.stringify({
                event: 'myEvent',
                data: 'string'
            }));
        });
    });
    it('should call only the correct event-listeners when event is emitted from a client', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        server.on('someotherEvent', function() {
            done(new Error());
        });
        server.on('myEvent', function() {
            done();
        });

        client.on('open', function open() {
            client.send(JSON.stringify({
                event: 'myEvent',
                data: 'string'
            }));
        });
    });
    it('should send event server.availableEvents.unkown when the data is not a string in the form { event: \'name\', data: \'data\'}', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        server.on(server.availableEvents.error, function() {
            done(new Error('$error should not be called'));
        });
        server.on(server.availableEvents.unkown, function(data) {
            expect(data).to.equal('test');
            done();
        });
        client.on('open', function open() {
            client.send('test');
        });
    });
    it('should call all event-listeners when event is emitted from a client', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        var spy = chai.spy();
        server.on('myEvent', spy);
        server.on('myEvent', spy);

        client.on('open', function open() {
            client.send(JSON.stringify({
                event: 'myEvent',
                data: 'string'
            }));
            client.close();
        });
        client.on('close', function() {
            expect(spy).to.be.called.twice();
            done();
        });
    });
});

describe('emit', function() {
    it('should exist', function() {
        expect(typeof server.emit).to.equal('function');
    });
    it('should accept only a string and enything except a function', function() {
        expect(server.emit.bind(server, 5, 'doStuff')).to.throw('Need a string as first argument and no function as second.');
        expect(server.emit.bind(server, '5', function() {})).to.throw('Need a string as first argument and no function as second.');
        expect(server.emit.bind(server, '5', {
            test: 1
        })).not.to.throw();
    });
    it('should send events to a client in the form { event: \'name\', data: \'data\'}', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        client.on('open', function open() {
            client.on('message', function(data) {
                expect(JSON.parse.bind(JSON, data)).not.to.throw();
                var decoded = JSON.parse(data);
                expect(decoded.event).to.equal('myEvent');
                expect(decoded.data).to.equal('data');
                done();
                server.close();
            });
            server.emit('myEvent', 'data');
        });
    });
    it('should send events to all clients in the form { event: \'name\', data: \'data\'}', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        var client2 = new WebSocket('ws://localhost:' + port);

        function onEvent(data) {
            expect(JSON.parse.bind(JSON, data)).not.to.throw();
            var decoded = JSON.parse(data);
            expect(decoded.event).to.equal('myEvent');
            expect(decoded.data).to.equal('data');
            server.close();
        }

        var spy = chai.spy(onEvent);
        client.on('open', function() {
            client.on('message', spy);
        });
        client2.on('open', function() {
            client2.on('message', spy);
            server.emit('myEvent', 'data');
        });
        client.on('close', function() {
            expect(spy).to.be.called.twice();
            done();
        });
    });
});
<commit_msg>cleanup<commit_after>'use strict';
var chai = require('chai');
var spies = require('chai-spies');
chai.use(spies);
var expect = chai.expect;
var angularWebsockets = require('./');
var WebSocket = require('ws');
var port = 8888;

var server = angularWebsockets({
    port: port
});

beforeEach(function() {
    server.close();
    server = angularWebsockets({
        port: port
    });
});

it('should connect', function(done) {
    var ws = new WebSocket('ws://localhost:' + port);
    ws.on('open', function open() {
        done();
    });
});

describe('availableEvents', function() {
    it('should have exist and be an object', function() {
        expect(typeof server.availableEvents).to.equal('object');
    });
    it('should have property \'close\' of type string', function() {
        expect(typeof server.availableEvents.close).to.equal('string');
    });
    it('should have property \'error\' of type string', function() {
        expect(typeof server.availableEvents.error).to.equal('string');
    });
    it('should have property \'unkown\' of type string', function() {
        expect(typeof server.availableEvents.unkown).to.equal('string');
    });
    it('should have property \'message\' of type string', function() {
        expect(typeof server.availableEvents.message).to.equal('string');
    });
});

describe('close', function() {
    it('should have exist and be a function', function() {
        expect(typeof server.close).to.equal('function');
    });
    it('should close the server connections', function(done) {
        var ws = new WebSocket('ws://localhost:' + port);
        ws.on('close', function() {
            done();
        });
        ws.on('open', function open() {
            server.close();
        });
    });
    it('should call on-\'server.availableEvents.close\'-listeners once when closing the server', function() {
        var spy = chai.spy();
        server.on(server.availableEvents.close, spy);
        server.close();
        expect(spy).to.be.called.once();
    });
    it('should call all on-server.availableEvents.close-listeners once when closing the server', function() {
        var spy = chai.spy();
        server.on(server.availableEvents.close, spy);
        server.on(server.availableEvents.close, spy);
        server.close();
        expect(spy).to.be.called.twice();
    });
});

describe('on', function() {
    it('should have exist and be a function', function() {
        expect(typeof server.on).to.equal('function');
    });
    it('should accept only a string and a function as argument', function() {
        expect(server.on.bind(server, 5, 'doStuff')).to.throw('Need a string as first argument and a function as second.');
        expect(server.on.bind(server, '5', 'doStuff')).to.throw('Need a string as first argument and a function as second.');
        expect(server.on.bind(server, '5', {
            test: 1
        })).to.throw('Need a string as first argument and a function as second.');
        expect(server.on.bind(server, '5', function() {})).not.to.throw();
    });
    it('should call the event-listener when event is emitted from a client', function(done) {
        var ws = new WebSocket('ws://localhost:' + port);
        server.on('myEvent', function() {
            done();
        });
        ws.on('open', function open() {
            ws.send(JSON.stringify({
                event: 'myEvent',
                data: 'string'
            }));
        });
    });
    it('should call only the correct event-listeners when event is emitted from a client', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        server.on('someotherEvent', function() {
            done(new Error());
        });
        server.on('myEvent', function() {
            done();
        });

        client.on('open', function open() {
            client.send(JSON.stringify({
                event: 'myEvent',
                data: 'string'
            }));
        });
    });
    it('should send event server.availableEvents.unkown when the data is not a string in the form { event: \'name\', data: \'data\'}', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        server.on(server.availableEvents.error, function() {
            done(new Error('$error should not be called'));
        });
        server.on(server.availableEvents.unkown, function(data) {
            expect(data).to.equal('test');
            done();
        });
        client.on('open', function open() {
            client.send('test');
        });
    });
    it('should call all event-listeners when event is emitted from a client', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        var spy = chai.spy();
        server.on('myEvent', spy);
        server.on('myEvent', spy);

        client.on('open', function open() {
            client.send(JSON.stringify({
                event: 'myEvent',
                data: 'string'
            }));
            client.close();
        });
        client.on('close', function() {
            expect(spy).to.be.called.twice();
            done();
        });
    });
});

describe('emit', function() {
    it('should exist', function() {
        expect(typeof server.emit).to.equal('function');
    });
    it('should accept only a string and enything except a function', function() {
        expect(server.emit.bind(server, 5, 'doStuff')).to.throw('Need a string as first argument and no function as second.');
        expect(server.emit.bind(server, '5', function() {})).to.throw('Need a string as first argument and no function as second.');
        expect(server.emit.bind(server, '5', {
            test: 1
        })).not.to.throw();
    });
    it('should send events to a client in the form { event: \'name\', data: \'data\'}', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        client.on('open', function open() {
            client.on('message', function(data) {
                expect(JSON.parse.bind(JSON, data)).not.to.throw();
                var decoded = JSON.parse(data);
                expect(decoded.event).to.equal('myEvent');
                expect(decoded.data).to.equal('data');
                done();
                server.close();
            });
            server.emit('myEvent', 'data');
        });
    });
    it('should send events to all clients in the form { event: \'name\', data: \'data\'}', function(done) {
        var client = new WebSocket('ws://localhost:' + port);
        var client2 = new WebSocket('ws://localhost:' + port);

        function onEvent(data) {
            expect(JSON.parse.bind(JSON, data)).not.to.throw();
            var decoded = JSON.parse(data);
            expect(decoded.event).to.equal('myEvent');
            expect(decoded.data).to.equal('data');
            server.close();
        }

        var spy = chai.spy(onEvent);
        client.on('open', function() {
            client.on('message', spy);
        });
        client2.on('open', function() {
            client2.on('message', spy);
            server.emit('myEvent', 'data');
        });
        client.on('close', function() {
            expect(spy).to.be.called.twice();
            done();
        });
    });
});
<|endoftext|>


<commit_before>var Office365ConnectorHook = require("./index.js"),
    winston = require('winston');

var Logger = winston.Logger;
var Console = winston.transports.Console;

var logger = new Logger({
    transports: [
        new Console({}),
        new Office365ConnectorHook({
            hookUrl: 'https://outlook.office.com/webhook/28b98568-d712-43b0-acab-dc662d48af10@6afcd346-7cb2-46db-897d-c639dbdf0449/IncomingWebhook/292e9954dc38453ab8dca787d4dae2c3/26b2f7b0-a26a-43d3-b4e8-ccd198b6b3ef'
        })
    ]
});

logger.info('I am being logged here'); // will be sent to both console and Slack<commit_msg>Change comment reference to Team channel<commit_after>var Office365ConnectorHook = require("./index.js"),
    winston = require('winston');

var Logger = winston.Logger;
var Console = winston.transports.Console;

var logger = new Logger({
    transports: [
        new Console({}),
        new Office365ConnectorHook({
            hookUrl: 'https://outlook.office.com/webhook/28b98568-d712-43b0-acab-dc662d48af10@6afcd346-7cb2-46db-897d-c639dbdf0449/IncomingWebhook/292e9954dc38453ab8dca787d4dae2c3/26b2f7b0-a26a-43d3-b4e8-ccd198b6b3ef'
        })
    ]
});

logger.info('I am being logged here'); // will be sent to both console and channel<|endoftext|>


<commit_before>const test = require('ava');
const random = require('./helpers/random');
const all = require('./products');

test('all()', t => {
  t.true(all.length > 0);
});

test('random()', t => {
  t.truthy(random(all));
  t.not(random(all), random(all));
});
<commit_msg>🤖(break): 2017-7-6 08:32:52<commit_after>const test = require('ava');
const random = require('./helpers/random');
const all = require('./products');

test('all()', t => {
  t.true(all.length < 0);
});

test('random()', t => {
  t.truthy(random(all));
  t.not(random(all), random(all));
});
<|endoftext|>


<commit_before>/* global describe, it */

require('es6-promise').polyfill()

var popsicle = require('popsicle')
var nock = require('nock')
var expect = require('chai').expect
var prefix = require('./')

describe('popsicle prefix', function () {
  nock('http://prefix.com')
    .get('/http://example.com/')
    .reply(200)

  it('should prefix all urls', function () {
    return popsicle.get('http://example.com')
      .use(prefix('http://prefix.com'))
      .then(res => {
        expect(res.url).to.equal('http://prefix.com/http://example.com/')
      })
  })
})
<commit_msg>Correct old node version usage<commit_after>/* global describe, it */

require('es6-promise').polyfill()

var popsicle = require('popsicle')
var nock = require('nock')
var expect = require('chai').expect
var prefix = require('./')

describe('popsicle prefix', function () {
  nock('http://prefix.com')
    .get('/http://example.com/')
    .reply(200)

  it('should prefix all urls', function () {
    return popsicle.get('http://example.com')
      .use(prefix('http://prefix.com'))
      .then(function (res) {
        expect(res.url).to.equal('http://prefix.com/http://example.com/')
      })
  })
})
<|endoftext|>


<commit_before>const test = require('ava');
const random = require('./helpers/random');
const all = require('./products');

test('all()', t => {
  t.true(all.length > 0);
});

test('random()', t => {
  t.truthy(random(all));
  t.not(random(all), random(all));
});
<commit_msg>🤖(break): 2017-7-24 01:56:22<commit_after>const test = require('ava');
const random = require('./helpers/random');
const all = require('./products');

test('all()', t => {
  t.true(all.length < 0);
});

test('random()', t => {
  t.truthy(random(all));
  t.not(random(all), random(all));
});
<|endoftext|>


<commit_before>var avro = require("./build/Release/avro");

/*
  Tests for examples from specification
*/

function assertMatchesHex(schema, value, hex) {
    var buf = avro.jsonStringToAvroBuffer(JSON.stringify(schema), JSON.stringify(value));
    var bufHex = buf.toString("hex");
    if (hex !== bufHex) {
        throw "Value " + JSON.stringify(value) + " doesn't match specified hex '" + hex +
              "', has '" + bufHex + "' instead.";
    }
}

assertMatchesHex("string", "foo", "06666f6f");

var recordSchema =
  {
    "type": "record",
    "name": "test",
    "fields" : [
      {"name": "a", "type": "long"},
      {"name": "b", "type": "string"}
    ]
  };

var record = { "a": 27, "b": "foo" };

assertMatchesHex(recordSchema, record, "3606666f6f");

var arraySchema = { "type": "array", "items": "long" };

var array = [ 3, 27 ];

assertMatchesHex(arraySchema, array, "04063600");

var unionSchema = ["string", "null"];

assertMatchesHex(unionSchema, null, "02");

/*
  Test zigzag encoding from specification
*/

var zigzagSchema = "int";

assertMatchesHex(zigzagSchema, 0, "00");
assertMatchesHex(zigzagSchema, -1, "01");
assertMatchesHex(zigzagSchema, 1, "02");
assertMatchesHex(zigzagSchema, -2, "03");
assertMatchesHex(zigzagSchema, 2, "04");
assertMatchesHex(zigzagSchema, -64, "7f");
assertMatchesHex(zigzagSchema, 64, "8001");

/*
  Test roundtripping from JS to Avro and back to JS
*/

function assertRoundtrip(schema, value) {
    var schemaJson = JSON.stringify(schema);
    var valueJson = JSON.stringify(value);
    var buf = avro.jsonStringToAvroBuffer(schemaJson, valueJson);
    var json = avro.avroBufferToJsonString(schemaJson, buf);
    if (json !== valueJson) {
        throw "Value " + valueJson + " doesn't match " + json + ".";
    }
}

assertRoundtrip("string", "foo");
assertRoundtrip("int", 12);
assertRoundtrip("long", 12);

<commit_msg>Add 2 more roundtrip tests.<commit_after>var avro = require("./build/Release/avro");

/*
  Tests for examples from specification
*/

function assertMatchesHex(schema, value, hex) {
    var buf = avro.jsonStringToAvroBuffer(JSON.stringify(schema), JSON.stringify(value));
    var bufHex = buf.toString("hex");
    if (hex !== bufHex) {
        throw "Value " + JSON.stringify(value) + " doesn't match specified hex '" + hex +
              "', has '" + bufHex + "' instead.";
    }
}

assertMatchesHex("string", "foo", "06666f6f");

var recordSchema =
  {
    "type": "record",
    "name": "test",
    "fields" : [
      {"name": "a", "type": "long"},
      {"name": "b", "type": "string"}
    ]
  };

var record = { "a": 27, "b": "foo" };

assertMatchesHex(recordSchema, record, "3606666f6f");

var arraySchema = { "type": "array", "items": "long" };

var array = [ 3, 27 ];

assertMatchesHex(arraySchema, array, "04063600");

var unionSchema = ["string", "null"];

assertMatchesHex(unionSchema, null, "02");

/*
  Test zigzag encoding from specification
*/

var zigzagSchema = "int";

assertMatchesHex(zigzagSchema, 0, "00");
assertMatchesHex(zigzagSchema, -1, "01");
assertMatchesHex(zigzagSchema, 1, "02");
assertMatchesHex(zigzagSchema, -2, "03");
assertMatchesHex(zigzagSchema, 2, "04");
assertMatchesHex(zigzagSchema, -64, "7f");
assertMatchesHex(zigzagSchema, 64, "8001");

/*
  Test roundtripping from JS to Avro and back to JS
*/

function assertRoundtrip(schema, value) {
    var schemaJson = JSON.stringify(schema);
    var valueJson = JSON.stringify(value);
    var buf = avro.jsonStringToAvroBuffer(schemaJson, valueJson);
    var json = avro.avroBufferToJsonString(schemaJson, buf);
    if (json !== valueJson) {
        throw "Value " + valueJson + " doesn't match " + json + ".";
    }
}

assertRoundtrip("string", "foo");
assertRoundtrip("int", 12);
assertRoundtrip("long", 12);
assertRoundtrip({ "type": "array", "items": "string" },
                [ "a", "b", "c" ]);
assertRoundtrip({ "type": "record", "name": "test", "fields" : [ {"name": "a", "type": "long"} ] },
                { "a": 12 });
<|endoftext|>


<commit_before>/* eslint-env mocha */

'use strict';

const assert = require('assert');
const p = require('child_process');
const exec = p.exec;
const spawn = p.spawn;
const path = require('path');
const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const express = require('express');
const request = require('supertest');
const bodyParser = require('body-parser');

const data = {
	foo: 'bar',
	lorem: 'Ipsum',
	a: {
		b: 'c'
	}
};

const postData = {
	success: true
};

const putData = {
	x: 'foo'
};

express()
	.get('/data', (req, res) => {
		res.json(data);
	})
	.post('/data', (req, res) => {
		res.json(postData);
	})
	.put('/data', (req, res) => {
		res.json(putData);
	})
	.listen(9194);

describe('snapstub', function () {
	before(function (done) {
		mkdirp(path.join(__dirname, '__mocks__'), done);
	});
	after(function (done) {
		rimraf(path.join(__dirname, '__mocks__'), done);
	});
	it('should correctly save a snapshot', function (done) {
		exec('./index.js add http://localhost:9194/data', (err, stdout) => {
			if (err) {
				done(err);
			}
			const expectedFileName = path.join(__dirname, '__mocks__', 'data', 'get.json');
			assert.strictEqual(
				stdout.trim(),
				`✔  Successfully added: ${expectedFileName}`
			);
			done();
		});
	});
	it('should correctly save many snapshot methods', function (done) {
		exec('./index.js add http://localhost:9194/data --method=post,head', (err, stdout) => {
			if (err) {
				done(err);
			}
			const postExpectedFileName = path.join(__dirname, '__mocks__', 'data', 'post.json');
			const headExpectedFileName = path.join(__dirname, '__mocks__', 'data', 'head.json');
			assert.strictEqual(
				stdout.trim(),
				`✔  Successfully added: ${postExpectedFileName}
✔  Successfully added: ${headExpectedFileName}`
			);
			done();
		});
	});
	it('should be able to set a custom header when adding snapshots', function (done) {
		express()
			.get('/data', (req, res) => {
				assert.strictEqual(req.get('X-Token'), '0123F');
				res.sendStatus(200);
				done();
			})
			.listen(9195, e => {
				if (e) {
					done(e);
				}
				exec('./index.js add http://localhost:9195/data --header "X-Token: 0123F"', err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to set multiple custom headers when adding snapshots', function (done) {
		express()
			.get('/data', (req, res) => {
				assert.strictEqual(req.get('X-Foo'), 'bar');
				assert.strictEqual(req.get('X-Token'), '0123F');
				res.sendStatus(200);
				done();
			})
			.listen(9196, e => {
				if (e) {
					done(e);
				}
				exec('./index.js add http://localhost:9196/data --header "X-Token: 0123F" --header "X-Foo: bar"', err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to POST simple json data', function (done) {
		const bodyData = {
			foo: 'Bar'
		};
		express()
			.use(bodyParser.json())
			.post('/data', (req, res) => {
				assert.deepStrictEqual(req.body, bodyData);
				res.sendStatus(200);
				done();
			})
			.listen(9200, e => {
				if (e) {
					done(e);
				}
				exec('./index.js add http://localhost:9200/data --data \'{ "foo": "Bar" }\'', err => { // eslint-disable-line no-useless-escape
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to POST json data', function (done) {
		const bodyData = {
			foo: 'bar',
			more: {
				lorem: 'ipsum',
				dolor: 'sit'
			}
		};
		express()
			.use(bodyParser.json())
			.post('/data', (req, res) => {
				assert.deepStrictEqual(req.body, bodyData);
				res.sendStatus(200);
				done();
			})
			.listen(9197, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9197/data --data '${JSON.stringify(bodyData)}'`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to POST form data', function (done) {
		const bodyData = 'parameter=value&also=another';
		express()
			.use(bodyParser.urlencoded({extended: true}))
			.post('/data', (req, res) => {
				assert.strictEqual(req.body.parameter, 'value');
				assert.strictEqual(req.body.also, 'another');
				res.sendStatus(200);
				done();
			})
			.listen(9198, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9198/data --data "${bodyData}"`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to PUT form data', function (done) {
		const bodyData = 'parameter=something';
		express()
			.use(bodyParser.urlencoded({extended: true}))
			.put('/data', (req, res) => {
				assert.strictEqual(req.body.parameter, 'something');
				res.sendStatus(200);
				done();
			})
			.listen(9199, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9199/data --data "${bodyData}" --method=put`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to send from data file', function (done) {
		express()
			.use(bodyParser.urlencoded({extended: true}))
			.post('/data', (req, res) => {
				assert.strictEqual(req.body.dolor.trim(), 'sit');
				res.sendStatus(200);
				done();
			})
			.listen(9201, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9201/data --data ./fixtures/data`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to send from json data file', function (done) {
		express()
			.use(bodyParser.json())
			.post('/data', (req, res) => {
				assert.strictEqual(req.body.foo, 'Lorem');
				res.sendStatus(200);
				done();
			})
			.listen(9202, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9202/data --data ./fixtures/data.json`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should correctly retrieve snapshot data', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			setTimeout(() => {
				request('http://localhost:8059')
					.get('/data')
					.expect('Content-Type', /json/)
					.expect(data)
					.end(() => { // eslint-disable-line
						child.kill();
						done(err);
					});
			}, 2000);
		});
	});
	it('should correctly retrieve snapshot data from post method', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data --method=post', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			setTimeout(() => {
				request('http://localhost:8059')
					.post('/data')
					.expect('Content-Type', /json/)
					.expect(postData)
					.end(err => { // eslint-disable-line
						child.kill();
						done(err);
					});
			}, 2000);
		});
	});
	it('should correctly retrieve snapshot data from multiple http methods', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data --method=post,get,put', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			setTimeout(() => {
				request('http://localhost:8059')
					.put('/data')
					.expect('Content-Type', /json/)
					.expect(putData)
					.end(err => { // eslint-disable-line
						child.kill();
						done(err);
					});
			}, 2000);
		});
	});
	it('should not print messages to console by default', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			child.stdout.once('data', data => {
				assert.equal(data.toString(), '✔  Successfully launched snapstub server on: http://localhost:8059\n');
				child.stdout.once('data', d => {
					assert.equal(d.toString(), 'ℹ  http://localhost:8059/data/\n');
				});
			});
			setTimeout(() => {
				child.kill();
				done(err);
			}, 2000);
		});
	});
	it('should print messages to console when using --verbose option', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start', '--verbose']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			child.stdout.on('data', data => {
				assert.notEqual(data.toString().split('pathToMocks'), -1);
				child.kill();
				done(err);
			});
		});
	});
	it('should get help message when using no valid command', function (done) {
		exec('./index.js', (err, stdout) => {
			assert.strictEqual(stdout.indexOf('Usage:'), 1);
			done(err);
		});
	});
	it('should get version number when using --version flag', function (done) {
		exec('./index.js --version', (err, stdout) => {
			assert.strictEqual(stdout.trim(), require('./package.json').version);
			done(err);
		});
	});
});

<commit_msg>Refactored test lint warning<commit_after>/* eslint-env mocha */

'use strict';

const assert = require('assert');
const p = require('child_process');
const exec = p.exec;
const spawn = p.spawn;
const path = require('path');
const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const express = require('express');
const request = require('supertest');
const bodyParser = require('body-parser');

const data = {
	foo: 'bar',
	lorem: 'Ipsum',
	a: {
		b: 'c'
	}
};

const postData = {
	success: true
};

const putData = {
	x: 'foo'
};

express()
	.get('/data', (req, res) => {
		res.json(data);
	})
	.post('/data', (req, res) => {
		res.json(postData);
	})
	.put('/data', (req, res) => {
		res.json(putData);
	})
	.listen(9194);

describe('snapstub', function () {
	before(function (done) {
		mkdirp(path.join(__dirname, '__mocks__'), done);
	});
	after(function (done) {
		rimraf(path.join(__dirname, '__mocks__'), done);
	});
	it('should correctly save a snapshot', function (done) {
		exec('./index.js add http://localhost:9194/data', (err, stdout) => {
			if (err) {
				done(err);
			}
			const expectedFileName = path.join(__dirname, '__mocks__', 'data', 'get.json');
			assert.strictEqual(
				stdout.trim(),
				`✔  Successfully added: ${expectedFileName}`
			);
			done();
		});
	});
	it('should correctly save many snapshot methods', function (done) {
		exec('./index.js add http://localhost:9194/data --method=post,head', (err, stdout) => {
			if (err) {
				done(err);
			}
			const postExpectedFileName = path.join(__dirname, '__mocks__', 'data', 'post.json');
			const headExpectedFileName = path.join(__dirname, '__mocks__', 'data', 'head.json');
			assert.strictEqual(
				stdout.trim(),
				`✔  Successfully added: ${postExpectedFileName}
✔  Successfully added: ${headExpectedFileName}`
			);
			done();
		});
	});
	it('should be able to set a custom header when adding snapshots', function (done) {
		express()
			.get('/data', (req, res) => {
				assert.strictEqual(req.get('X-Token'), '0123F');
				res.sendStatus(200);
				done();
			})
			.listen(9195, e => {
				if (e) {
					done(e);
				}
				exec('./index.js add http://localhost:9195/data --header "X-Token: 0123F"', err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to set multiple custom headers when adding snapshots', function (done) {
		express()
			.get('/data', (req, res) => {
				assert.strictEqual(req.get('X-Foo'), 'bar');
				assert.strictEqual(req.get('X-Token'), '0123F');
				res.sendStatus(200);
				done();
			})
			.listen(9196, e => {
				if (e) {
					done(e);
				}
				exec('./index.js add http://localhost:9196/data --header "X-Token: 0123F" --header "X-Foo: bar"', err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to POST simple json data', function (done) {
		const bodyData = {
			foo: 'Bar'
		};
		express()
			.use(bodyParser.json())
			.post('/data', (req, res) => {
				assert.deepStrictEqual(req.body, bodyData);
				res.sendStatus(200);
				done();
			})
			.listen(9200, e => {
				if (e) {
					done(e);
				}
				exec('./index.js add http://localhost:9200/data --data \'{ "foo": "Bar" }\'', err => { // eslint-disable-line no-useless-escape
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to POST json data', function (done) {
		const bodyData = {
			foo: 'bar',
			more: {
				lorem: 'ipsum',
				dolor: 'sit'
			}
		};
		express()
			.use(bodyParser.json())
			.post('/data', (req, res) => {
				assert.deepStrictEqual(req.body, bodyData);
				res.sendStatus(200);
				done();
			})
			.listen(9197, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9197/data --data '${JSON.stringify(bodyData)}'`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to POST form data', function (done) {
		const bodyData = 'parameter=value&also=another';
		express()
			.use(bodyParser.urlencoded({extended: true}))
			.post('/data', (req, res) => {
				assert.strictEqual(req.body.parameter, 'value');
				assert.strictEqual(req.body.also, 'another');
				res.sendStatus(200);
				done();
			})
			.listen(9198, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9198/data --data "${bodyData}"`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to PUT form data', function (done) {
		const bodyData = 'parameter=something';
		express()
			.use(bodyParser.urlencoded({extended: true}))
			.put('/data', (req, res) => {
				assert.strictEqual(req.body.parameter, 'something');
				res.sendStatus(200);
				done();
			})
			.listen(9199, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9199/data --data "${bodyData}" --method=put`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to send from data file', function (done) {
		express()
			.use(bodyParser.urlencoded({extended: true}))
			.post('/data', (req, res) => {
				assert.strictEqual(req.body.dolor.trim(), 'sit');
				res.sendStatus(200);
				done();
			})
			.listen(9201, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9201/data --data ./fixtures/data`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should be able to send from json data file', function (done) {
		express()
			.use(bodyParser.json())
			.post('/data', (req, res) => {
				assert.strictEqual(req.body.foo, 'Lorem');
				res.sendStatus(200);
				done();
			})
			.listen(9202, e => {
				if (e) {
					done(e);
				}
				exec(`./index.js add http://localhost:9202/data --data ./fixtures/data.json`, err => {
					if (err) {
						done(err);
					}
				});
			});
	});
	it('should correctly retrieve snapshot data', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			setTimeout(() => {
				request('http://localhost:8059')
					.get('/data')
					.expect('Content-Type', /json/)
					.expect(data)
					.end(() => { // eslint-disable-line
						child.kill();
						done(err);
					});
			}, 2000);
		});
	});
	it('should correctly retrieve snapshot data from post method', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data --method=post', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			setTimeout(() => {
				request('http://localhost:8059')
					.post('/data')
					.expect('Content-Type', /json/)
					.expect(postData)
					.end(err => { // eslint-disable-line
						child.kill();
						done(err);
					});
			}, 2000);
		});
	});
	it('should correctly retrieve snapshot data from multiple http methods', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data --method=post,get,put', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			setTimeout(() => {
				request('http://localhost:8059')
					.put('/data')
					.expect('Content-Type', /json/)
					.expect(putData)
					.end(err => { // eslint-disable-line
						child.kill();
						done(err);
					});
			}, 2000);
		});
	});
	it('should print route messages to console by default', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			function validateRouteMsg() {
				child.stdout.once('data', d => {
					assert.equal(d.toString(), 'ℹ  http://localhost:8059/data/\n');
				});
			}
			function validateSuccessMsg() {
				child.stdout.once('data', data => {
					assert.equal(data.toString(), '✔  Successfully launched snapstub server on: http://localhost:8059\n');
					validateRouteMsg();
				});
			}
			validateSuccessMsg();
			setTimeout(() => {
				child.kill();
				done(err);
			}, 2000);
		});
	});
	it('should print messages to console when using --verbose option', function (done) {
		this.timeout(6000);
		exec('./index.js add http://localhost:9194/data', err => {
			if (err) {
				done(err);
			}
			const child = spawn('./index.js', ['start', '--verbose']);
			child.stderr.on('data', err => {
				throw new Error(err.toString());
			});
			child.stdout.on('data', data => {
				assert.notEqual(data.toString().split('pathToMocks'), -1);
				child.kill();
				done(err);
			});
		});
	});
	it('should get help message when using no valid command', function (done) {
		exec('./index.js', (err, stdout) => {
			assert.strictEqual(stdout.indexOf('Usage:'), 1);
			done(err);
		});
	});
	it('should get version number when using --version flag', function (done) {
		exec('./index.js --version', (err, stdout) => {
			assert.strictEqual(stdout.trim(), require('./package.json').version);
			done(err);
		});
	});
});

<|endoftext|>


<commit_before>'use strict';

var BinBuild = require('./');
var fs = require('fs');
var path = require('path');
var test = require('ava');

test('expose a constructor', function (t) {
	t.plan(1);
	t.assert(typeof BinBuild === 'function');
});

test('set source file', function (t) {
	t.plan(1);

	var build = new BinBuild()
		.src('src.tar.gz');

	t.assert(build._src === 'src.tar.gz');
});

test('add commands to run', function (t) {
	t.plan(2);

	var build = new BinBuild()
		.cmd('make')
		.cmd('make install');

	t.assert(build._cmd[0] === 'make');
	t.assert(build._cmd[1] === 'make install');
});

test('should download and build source', function (t) {
	t.plan(2);

	var tmp = path.join(__dirname, 'tmp');
	var cmd = [
		'./configure --disable-gifview --disable-gifdiff',
		'--prefix="' + tmp + '" --bindir="' + tmp + '"'
	].join(' ');

	var build = new BinBuild()
		.src('http://www.lcdf.org/gifsicle/gifsicle-1.84.tar.gz')
		.cmd('autoreconf -ivf')
		.cmd(cmd)
		.cmd('make install');

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

		fs.exists(path.join(tmp, 'gifsicle'), function (exists) {
			t.assert(exists);
		});
	});
});
<commit_msg>Show errors in tests<commit_after>'use strict';

var BinBuild = require('./');
var fs = require('fs');
var path = require('path');
var test = require('ava');

test('expose a constructor', function (t) {
	t.plan(1);
	t.assert(typeof BinBuild === 'function');
});

test('set source file', function (t) {
	t.plan(1);

	var build = new BinBuild()
		.src('src.tar.gz');

	t.assert(build._src === 'src.tar.gz');
});

test('add commands to run', function (t) {
	t.plan(2);

	var build = new BinBuild()
		.cmd('make')
		.cmd('make install');

	t.assert(build._cmd[0] === 'make');
	t.assert(build._cmd[1] === 'make install');
});

test('should download and build source', function (t) {
	t.plan(2);

	var tmp = path.join(__dirname, 'tmp');
	var cmd = [
		'./configure --disable-gifview --disable-gifdiff',
		'--prefix="' + tmp + '" --bindir="' + tmp + '"'
	].join(' ');

	var build = new BinBuild()
		.src('http://www.lcdf.org/gifsicle/gifsicle-1.84.tar.gz')
		.cmd('autoreconf -ivf')
		.cmd(cmd)
		.cmd('make install');

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

		fs.exists(path.join(tmp, 'gifsicle'), function (exists) {
			t.assert(exists);
		});
	});
});
<|endoftext|>


<commit_before>import { blazyb, sref, Zerotorescue } from 'MAINTAINERS';

export default [
  {
    date: new Date('2018-01-07'),
    changes: 'Clearcasting module now shows percent used instead of percent missed, tooltip updated, and now works with MoC',
    contributors: [sref],
  },
  {
    date: new Date('2017-12-24'),
    changes: 'Fixed crash with the new Insignia of the Grand Army module.',
    contributors: [Zerotorescue],
  },
  {
    date: new Date('2017-12-07'),
    changes: 'Stat values show healing gained per 1 rating on hover.',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-12-05'),
    changes: 'Added throughput for some NLC traits.',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-10-23'),
    changes: 'Added Stat Weights calculator',
    contributors: [sref],
  },
  {
    date: new Date('2017-10-14'),
    changes: "Now uses the base Sephuz's Secret module, which displays average haste gained.",
    contributors: [sref],
  },
  {
    date: new Date('2017-10-06'),
    changes: 'Added Ironbark module.',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-29'),
    changes: 'Flourish display updates.',
    contributors: [blazyb, sref],
  },
  {
    date: new Date('2017-09-26'),
    changes: 'Added suggestions for Soul of the Forest / Archdruid WG usage',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-23'),
    changes: 'Updated Mastery calculations to be less friendly to overhealing. Expect lower results from Cultivation, Cenarion Ward, Spring Blossoms, and 2PT19.',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-22'),
    changes: 'Updated display of 2PT20 to show average refunded cooldown instead of throughput estimate.',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-21'),
    changes: 'Minor bug fix to clearcasting module.',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-19'),
    changes: 'Added Average HoTs statistic',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-18'),
    changes: "Added Essence of G'Hanir to the cooldowns tab",
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Added relic traits module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-07'),
    changes: "Added suggestion when high Nature's Essence overheal",
    contributors: [sref],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Added preliminary support for T21',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Activated low health healing module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Added suggestions for low healing from Cultivation and Spring Blossoms',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-04'),
    changes: 'Added Mastery calculations, with support for Spring Blossoms, Cenarion Ward, Cultivation, and the T19 2Set',
    contributors: [sref],
  },
  {
    date: new Date('2017-07-06'),
    changes: 'Added mana costs for spells, and the cooldown tab should now properly calculate mana costs',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-07-06'),
    changes: 'Fixed a bug in 4PT20 calculations, and added Swiftmend to the cast efficiency tab',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-23'),
    changes: "Added Essence of G'Hanir module",
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-20'),
    changes: 'Added Gnawed Thumb Ring module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-16'),
    changes: 'Adjustments to DMD:Promises module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-01'),
    changes: 'Updated T20 calculations based on PTR changes',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-30'),
    changes: 'Added Dreamwalker calculations (thanks @greatman)',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-30'),
    changes: 'Added SotF + SotA modules',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-26'),
    changes: 'Added non-healing time and downtime calculations',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-26'),
    changes: 'Added Chameleon Song module. Also updated Tree of Life module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-25'),
    changes: 'Added T20 module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-21'),
    changes: 'Added Resto Druid Analyzer',
    contributors: [blazyb],
  },
];
<commit_msg>Updated changelog<commit_after>import { blazyb, sref, Zerotorescue } from 'MAINTAINERS';

export default [
  {
    date: new Date('2018-01-10'),
    changes: 'Added framework for tracking HoT attribution, allowing updates to several modules: Tearstone of Elune, Power of the Archdruid, T21 2pc, and T21 4pc. Also added T19 4pc module.',
    contributors: [sref],
  },
  {
    date: new Date('2018-01-07'),
    changes: 'Clearcasting module now shows percent used instead of percent missed, tooltip updated, and now works with MoC',
    contributors: [sref],
  },
  {
    date: new Date('2017-12-24'),
    changes: 'Fixed crash with the new Insignia of the Grand Army module.',
    contributors: [Zerotorescue],
  },
  {
    date: new Date('2017-12-07'),
    changes: 'Stat values show healing gained per 1 rating on hover.',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-12-05'),
    changes: 'Added throughput for some NLC traits.',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-10-23'),
    changes: 'Added Stat Weights calculator',
    contributors: [sref],
  },
  {
    date: new Date('2017-10-14'),
    changes: "Now uses the base Sephuz's Secret module, which displays average haste gained.",
    contributors: [sref],
  },
  {
    date: new Date('2017-10-06'),
    changes: 'Added Ironbark module.',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-29'),
    changes: 'Flourish display updates.',
    contributors: [blazyb, sref],
  },
  {
    date: new Date('2017-09-26'),
    changes: 'Added suggestions for Soul of the Forest / Archdruid WG usage',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-23'),
    changes: 'Updated Mastery calculations to be less friendly to overhealing. Expect lower results from Cultivation, Cenarion Ward, Spring Blossoms, and 2PT19.',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-22'),
    changes: 'Updated display of 2PT20 to show average refunded cooldown instead of throughput estimate.',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-21'),
    changes: 'Minor bug fix to clearcasting module.',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-19'),
    changes: 'Added Average HoTs statistic',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-18'),
    changes: "Added Essence of G'Hanir to the cooldowns tab",
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Added relic traits module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-07'),
    changes: "Added suggestion when high Nature's Essence overheal",
    contributors: [sref],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Added preliminary support for T21',
    contributors: [sref],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Activated low health healing module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-07'),
    changes: 'Added suggestions for low healing from Cultivation and Spring Blossoms',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-09-04'),
    changes: 'Added Mastery calculations, with support for Spring Blossoms, Cenarion Ward, Cultivation, and the T19 2Set',
    contributors: [sref],
  },
  {
    date: new Date('2017-07-06'),
    changes: 'Added mana costs for spells, and the cooldown tab should now properly calculate mana costs',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-07-06'),
    changes: 'Fixed a bug in 4PT20 calculations, and added Swiftmend to the cast efficiency tab',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-23'),
    changes: "Added Essence of G'Hanir module",
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-20'),
    changes: 'Added Gnawed Thumb Ring module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-16'),
    changes: 'Adjustments to DMD:Promises module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-06-01'),
    changes: 'Updated T20 calculations based on PTR changes',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-30'),
    changes: 'Added Dreamwalker calculations (thanks @greatman)',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-30'),
    changes: 'Added SotF + SotA modules',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-26'),
    changes: 'Added non-healing time and downtime calculations',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-26'),
    changes: 'Added Chameleon Song module. Also updated Tree of Life module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-25'),
    changes: 'Added T20 module',
    contributors: [blazyb],
  },
  {
    date: new Date('2017-05-21'),
    changes: 'Added Resto Druid Analyzer',
    contributors: [blazyb],
  },
];
<|endoftext|>


<commit_before>import Vue from 'vue'
import Router from 'vue-router'
import App from './App'

require('./assets/js/site.js')

Vue.config.productionTip = false

Vue.use(Router)

const router = new Router({
  routes: [
    { path: '/Positions', alias: '/', component: () => import('@/components/Positions') },
    { path: '/Performance', component: () => import('@/components/Performance') },
    { path: '/Cashflow', component: () => import('@/components/Cashflow') },
    { path: '/ClosedPositions', component: () => import('@/components/ClosedPositions') },
    { path: '/PositionDetails', component: () => import('@/components/PositionDetails') }
  ],
  linkActiveClass: 'active',
  linkExactActiveClass: 'active'
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

require('../node_modules/bootstrap/dist/css/bootstrap.min.css')
require('./assets/css/site.css')
<commit_msg>dead code removed<commit_after>import Vue from 'vue'
import Router from 'vue-router'
import App from './App'

require('./assets/js/site.js')

Vue.config.productionTip = false

Vue.use(Router)

const router = new Router({
  routes: [
    { path: '/Positions', alias: '/', component: () => import('@/components/Positions') },
    { path: '/Performance', component: () => import('@/components/Performance') },
    { path: '/Cashflow', component: () => import('@/components/Cashflow') },
    { path: '/ClosedPositions', component: () => import('@/components/ClosedPositions') },
    { path: '/PositionDetails', component: () => import('@/components/PositionDetails') }
  ],
  linkActiveClass: 'active',
  linkExactActiveClass: 'active'
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
<|endoftext|>


<commit_before>/**
 * Profile domain model. A profile is part of a {@link User} and stores general information about the user.
 */
export default class Profile {
  /**
   * Create a Profile.
   *
   * @param {string} firstName - The first name of the {@link User}.
   * @param {string} lastName - The last name of the {@link User}.
   * @param {?string} [infix] - The infix of the {@link User}'s name.
   * @param {string} gender - The gender of the {@link User}.
   * @param {Date} birthDate - The birth date of the {@link User}.
   * @throws {Error} firstName parameter of type "string" is required.
   * @throws {Error} lastName parameter of type "string" is required.
   * @throws {Error} gender parameter of type "string" is required.
   * @throws {Error} birthDate parameter of type "Date" is required.
   */
  constructor(firstName, lastName, infix, gender, birthDate) {
    if (typeof firstName !== 'string') {
      throw new Error('firstName parameter of type "string" is required');
    }

    /**
     * The first name of the {@link User}.
     * @type {string}
     */
    this.firstName = firstName;

    if (typeof lastName !== 'string') {
      throw new Error('lastName parameter of type "string" is required');
    }

    /**
     * The last name of the {@link User}.
     * @type {string}
     */
    this.lastName = lastName;

    if (infix !== null && typeof infix !== 'string') {
      throw new Error('infix parameter of type "string|null" is required');
    }

    /**
     * @type {string} The infix of the {@link User}'s name.
     */
    this.infix = infix;

    if (typeof gender !== 'string') {
      throw new Error('gender parameter of type "string" is required');
    }

    /**
     * The gender of the {@link User}.
     * @type {string}
     */
    this.gender = gender;

    if (!(birthDate instanceof Date)) {
      throw new Error('birthDate parameter of type "string" is required');
    }

    /**
     * The birth date of the {@link User}.
     * @type {Date}
     */
    this.birthDate = birthDate;
  }
}
<commit_msg>refactor(profile): default infix parameter to null<commit_after>/**
 * Profile domain model. A profile is part of a {@link User} and stores general information about the user.
 */
export default class Profile {
  /**
   * Create a Profile.
   *
   * @param {string} firstName - The first name of the {@link User}.
   * @param {string} lastName - The last name of the {@link User}.
   * @param {?string} [infix] - The infix of the {@link User}'s name.
   * @param {string} gender - The gender of the {@link User}.
   * @param {Date} birthDate - The birth date of the {@link User}.
   * @throws {Error} firstName parameter of type "string" is required.
   * @throws {Error} lastName parameter of type "string" is required.
   * @throws {Error} gender parameter of type "string" is required.
   * @throws {Error} birthDate parameter of type "Date" is required.
   */
  constructor(firstName, lastName, infix = null, gender, birthDate) {
    if (typeof firstName !== 'string') {
      throw new Error('firstName parameter of type "string" is required');
    }

    /**
     * The first name of the {@link User}.
     * @type {string}
     */
    this.firstName = firstName;

    if (typeof lastName !== 'string') {
      throw new Error('lastName parameter of type "string" is required');
    }

    /**
     * The last name of the {@link User}.
     * @type {string}
     */
    this.lastName = lastName;

    if (infix !== null && typeof infix !== 'string') {
      throw new Error('infix parameter of type "string|null" is required');
    }

    /**
     * @type {string} The infix of the {@link User}'s name.
     */
    this.infix = infix;

    if (typeof gender !== 'string') {
      throw new Error('gender parameter of type "string" is required');
    }

    /**
     * The gender of the {@link User}.
     * @type {string}
     */
    this.gender = gender;

    if (!(birthDate instanceof Date)) {
      throw new Error('birthDate parameter of type "string" is required');
    }

    /**
     * The birth date of the {@link User}.
     * @type {Date}
     */
    this.birthDate = birthDate;
  }
}
<|endoftext|>


<commit_before>var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vestibulum euismod diam in blandit. Nam justo lectus, bibendum elementum eros at, euismod blandit nunc. Vivamus dapibus condimentum pulvinar. Curabitur nec orci ut mauris vestibulum gravida at eget lectus. In dignissim, leo quis malesuada ultrices, augue purus posuere odio, non rutrum risus nulla et urna. Pellentesque in mauris a est vulputate tempor vitae ut ex. Nunc in nunc vel sapien porttitor bibendum vel a magna. Duis quis nisl lacus. Praesent vitae lectus nec leo dapibus elementum. Phasellus leo metus, tincidunt quis risus ac, viverra viverra lacus. Maecenas consequat consectetur eleifend.';
var hackday_tour = (function ($, IN) {

	// Render the panel
	function panel(title, content, next, previous) {
		close();
		$('body').append('

');
		$('#tour_panel').append('x');
		$('#tour_panel').append('
' + title + '
');
		$('#tour_panel').append('
' + content + '
');
		$('#tour_panel').append('

');

		$('#tour_panel .close_panel').on('click', close);

		if (typeof next !== "undefined") {
			$('#tour_next_previous').append('Next »');
			$('#tour_next_previous .next').on('click', next);
		}

		if (typeof previous !== "undefined") {
			$('#tour_next_previous').append('« Previous');
			$('#tour_next_previous .previous').on('click', previous);
		}
	}

	function close() {
		$('#tour_panel').remove();
	}

	// First page of the tour
	function start_tour() {
		IN.User.authorize(function () {

			panel('Loading...', 'Loading...');

			// GET profile info
			IN.API.Raw("/people/~").result(function (profile) {
				IN.API.Raw("/people/~/picture-url").result(function (picture) {
					panel(' Welcome to your tour ' + profile.firstName,
						[
						'
This tour will help you discover content on ft.com.
',
						'
',
						'
Judges are awesome!
'
						].join(''), articles_by_industry);
				});
			});
		});
	}

	// Render an article in HTML
	function article(article, addclass) {
		var classes = ['article'];

		if (typeof addclass !== "undefined") {
			classes.push(addclass);
		}

		return [
			'
',
			'
', article.title, '
',
			'
', article.subhead, '
',
			'
Read more on ', article.title, '',
			'
',
		].join('')
	}

	function articles_by_industry() {
		IN.API.Raw("/people/~/industry").result(function (industry) {
			panel(industry, [
				article({ title: 'Headline 1', subhead: lorem}, 'main'),
				article({ title: 'Headline 2', subhead: lorem}),
				article({ title: 'Headline 3', subhead: lorem}),
				].join(''), articles_by_position, start_tour);
		});
	}

	function articles_by_position() {
		IN.API.Raw("/people/~/positions").result(function (positions) {
			panel(positions.values[0].title, [
				].join(''), articles_by_location, articles_by_industry);
		});
	}

	function articles_by_location (argument) {
		IN.API.Raw("/people/~/location").result(function (location) {
			panel(location.name, [
				'
',location.country.code,'
'
				].join(''), registered, articles_by_position);
		});
	}

	function registered() {
		IN.API.Raw("/people/~/email-address").result(function (email) {
			panel('You’re registered!', [
				'
We’ve used ', email, ' to register you.
',
				'
You’ve been sent an email with your details.
',
				'
Carry on reading articles
'
				].join(''), undefined, articles_by_location);
		});
	}

	function init() {
		// TODO Check if user is anonymous

		$('body').append('

');
		$('#start_tour')
			.html(['Use ',
				' ',
				'to
',
				'see what people similar
',
				'to you are reading on
',
				'',
				' »'
				].join(''))
			.on('click', function () {
				$(this).hide();
				start_tour()
			});
	}

	$(document).ready(init);

	return {
		start_tour: start_tour,
		panel: panel,
		article: article
	};

}(FT.$, IN));<commit_msg>move loading screen<commit_after>var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vestibulum euismod diam in blandit. Nam justo lectus, bibendum elementum eros at, euismod blandit nunc. Vivamus dapibus condimentum pulvinar. Curabitur nec orci ut mauris vestibulum gravida at eget lectus. In dignissim, leo quis malesuada ultrices, augue purus posuere odio, non rutrum risus nulla et urna. Pellentesque in mauris a est vulputate tempor vitae ut ex. Nunc in nunc vel sapien porttitor bibendum vel a magna. Duis quis nisl lacus. Praesent vitae lectus nec leo dapibus elementum. Phasellus leo metus, tincidunt quis risus ac, viverra viverra lacus. Maecenas consequat consectetur eleifend.';
var hackday_tour = (function ($, IN) {

	// Render the panel
	function panel(title, content, next, previous) {
		close();
		$('body').append('

');
		$('#tour_panel').append('x');
		$('#tour_panel').append('
' + title + '
');
		$('#tour_panel').append('
' + content + '
');
		$('#tour_panel').append('

');

		$('#tour_panel .close_panel').on('click', close);

		if (typeof next !== "undefined") {
			$('#tour_next_previous').append('Next »');
			$('#tour_next_previous .next').on('click', next);
		}

		if (typeof previous !== "undefined") {
			$('#tour_next_previous').append('« Previous');
			$('#tour_next_previous .previous').on('click', previous);
		}
	}

	function close() {
		$('#tour_panel').remove();
	}

	// First page of the tour
	function start_tour() {
		IN.User.authorize(function () {
			// GET profile info
			IN.API.Raw("/people/~").result(function (profile) {
				IN.API.Raw("/people/~/picture-url").result(function (picture) {
					panel(' Welcome to your tour ' + profile.firstName,
						[
						'
This tour will help you discover content on ft.com.
',
						'
',
						'
Judges are awesome!
'
						].join(''), articles_by_industry);
				});
			});
		});
	}

	// Render an article in HTML
	function article(article, addclass) {
		var classes = ['article'];

		if (typeof addclass !== "undefined") {
			classes.push(addclass);
		}

		return [
			'
',
			'
', article.title, '
',
			'
', article.subhead, '
',
			'
Read more on ', article.title, '',
			'
',
		].join('')
	}

	function articles_by_industry() {
		IN.API.Raw("/people/~/industry").result(function (industry) {
			panel(industry, [
				article({ title: 'Headline 1', subhead: lorem}, 'main'),
				article({ title: 'Headline 2', subhead: lorem}),
				article({ title: 'Headline 3', subhead: lorem}),
				].join(''), articles_by_position, start_tour);
		});
	}

	function articles_by_position() {
		IN.API.Raw("/people/~/positions").result(function (positions) {
			panel(positions.values[0].title, [
				].join(''), articles_by_location, articles_by_industry);
		});
	}

	function articles_by_location (argument) {
		IN.API.Raw("/people/~/location").result(function (location) {
			panel(location.name, [
				'
',location.country.code,'
'
				].join(''), registered, articles_by_position);
		});
	}

	function registered() {
		IN.API.Raw("/people/~/email-address").result(function (email) {
			panel('You’re registered!', [
				'
We’ve used ', email, ' to register you.
',
				'
You’ve been sent an email with your details.
',
				'
Carry on reading articles
'
				].join(''), undefined, articles_by_location);
		});
	}

	function init() {
		// TODO Check if user is anonymous

		$('body').append('

');
		$('#start_tour')
			.html(['Use ',
				' ',
				'to
',
				'see what people similar
',
				'to you are reading on
',
				'',
				' »'
				].join(''))
			.on('click', function () {
				$(this).hide();
				panel('Loading...', 'Loading...');
				start_tour()
			});
	}

	$(document).ready(init);

	return {
		start_tour: start_tour,
		panel: panel,
		article: article
	};

}(FT.$, IN));<|endoftext|>


<commit_before> // Load a user using the QuickUser class
user = new QuickUser();

// Read the user ID that was assigned
var id = user.get("id");
var hits = user.get("hits");
var registered = user.get("registered");

// Assign the register function to the onClick event of the register button
$('#registerButton').click( function() { register(); } );

$('.build').html(hits);

// If this user has been here several times ask them to register
if (hits >= 3) {
    // If they are not registered
    if (registered != true) {
        // Ask them to register
        $('.register').show();
    }
}

// Register the app
function register() {
    // Set the user value to registered
    user.set("registered", true);
    // If the email address is not blank
    if ($("#email").val() != '') {
        // Set the users email address
        user.set("email", $('#email').val() );
    }
    // Submit the email address to the API
    $.get('http://joeldare.com/register/', {from: 'Random Riff', os: navigator.platform, email: $('#email').val()});
    // Hide the dialog
    $('.register').hide();
}<commit_msg>Added a web/app identifier to the platform string that is logged.<commit_after> // Load a user using the QuickUser class
user = new QuickUser();

// Read the user ID that was assigned
var id = user.get("id");
var hits = user.get("hits");
var registered = user.get("registered");
var platform;

// Try to detect the platform using PhoneGap but default to Web
try {
    platform = device.platform;
} catch(err) {
    platform = 'Web';
}

// Assign the register function to the onClick event of the register button
$('#registerButton').click( function() { register(); } );

$('.build').html(hits);

// If this user has been here several times ask them to register
if (hits >= 3) {
    // If they are not registered
    if (registered != true) {
        // Ask them to register
        $('.register').show();
    }
}

// Register the app
function register() {
    // Set the user value to registered
    user.set("registered", true);
    // If the email address is not blank
    if ($("#email").val() != '') {
        // Set the users email address
        user.set("email", $('#email').val() );
    }
    // Submit the email address to the API
    $.get('http://joeldare.com/register/', {from: 'Random Riff', os: platform + ' ' + navigator.platform, email: $('#email').val()});
    // Hide the dialog
    $('.register').hide();
}<|endoftext|>


<commit_before>user_pref("beacon.enabled", false);
user_pref("browser.backspace_action", 0);
user_pref("browser.ctrlTab.recentlyUsedOrder", false);
user_pref("browser.discovery.enabled", false);
user_pref("browser.library.activity-stream.enabled", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", false);
user_pref("browser.newtabpage.enabled", false);
user_pref("browser.safebrowsing.downloads.enabled", false);
user_pref("browser.safebrowsing.malware.enabled", false);
user_pref("browser.safebrowsing.phishing.enabled", false);
user_pref("browser.search.widget.inNavBar", true);
user_pref("browser.startup.page", 3);
user_pref("browser.tabs.drawInTitlebar", true);
user_pref("browser.urlbar.suggest.searches", false);
user_pref("dom.forms.autocomplete.formautofill", true);
user_pref("extensions.formautofill.creditCards.available", true);
user_pref("extensions.pocket.enabled", false);
user_pref("general.autoScroll", true);
user_pref("general.smoothScroll", false);
user_pref("gfx.color_management.enablev4", true);
user_pref("gfx.webrender.compositor", true);
user_pref("javascript.options.asyncstack", false);
user_pref("media.eme.enabled", true);
user_pref("media.ffmpeg.vaapi.enabled", true);
user_pref("media.ffmpeg.dmabuf-textures.enabled", true);
user_pref("media.ffvpx.enabled", false);
user_pref("media.rdd-process.enabled", false);
user_pref("network.IDN_show_punycode", true);
user_pref("network.security.esni.enabled", true);
user_pref("network.trr.bootstrapAddress", "1.1.1.1");
user_pref("network.trr.mode", 2);
user_pref("privacy.donottrackheader.enabled", true);
<commit_msg>Re-enable RDD, disable Spectre mitigations for isolated CPs<commit_after>user_pref("beacon.enabled", false);
user_pref("browser.backspace_action", 0);
user_pref("browser.ctrlTab.recentlyUsedOrder", false);
user_pref("browser.discovery.enabled", false);
user_pref("browser.library.activity-stream.enabled", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", false);
user_pref("browser.newtabpage.enabled", false);
user_pref("browser.safebrowsing.downloads.enabled", false);
user_pref("browser.safebrowsing.malware.enabled", false);
user_pref("browser.safebrowsing.phishing.enabled", false);
user_pref("browser.search.widget.inNavBar", true);
user_pref("browser.startup.page", 3);
user_pref("browser.tabs.drawInTitlebar", true);
user_pref("browser.urlbar.suggest.searches", false);
user_pref("dom.forms.autocomplete.formautofill", true);
user_pref("extensions.formautofill.creditCards.available", true);
user_pref("extensions.pocket.enabled", false);
user_pref("general.autoScroll", true);
user_pref("general.smoothScroll", false);
user_pref("gfx.color_management.enablev4", true);
user_pref("gfx.webrender.compositor", true);
user_pref("javascript.options.asyncstack", false);
user_pref("javascript.options.spectre.disable_for_isolated_content", true);
user_pref("media.eme.enabled", true);
user_pref("media.ffmpeg.vaapi.enabled", true);
user_pref("media.ffmpeg.dmabuf-textures.enabled", true);
user_pref("media.ffvpx.enabled", false);
user_pref("network.IDN_show_punycode", true);
user_pref("network.security.esni.enabled", true);
user_pref("network.trr.bootstrapAddress", "1.1.1.1");
user_pref("network.trr.mode", 2);
user_pref("privacy.donottrackheader.enabled", true);
<|endoftext|>


<commit_before>/*! https://mths.be/utf8js v2.1.1 by @mathias */
;(function(root) {

	// Detect free variables `exports`
	var freeExports = typeof exports == 'object' && exports;

	// Detect free variable `module`
	var freeModule = typeof module == 'object' && module &&
		module.exports == freeExports && module;

	// Detect free variable `global`, from Node.js or Browserified code,
	// and use it as `root`
	var freeGlobal = typeof global == 'object' && global;
	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
		root = freeGlobal;
	}

	/*--------------------------------------------------------------------------*/

	var stringFromCharCode = String.fromCharCode;

	// Taken from https://mths.be/punycode
	function ucs2decode(string) {
		var output = [];
		var counter = 0;
		var length = string.length;
		var value;
		var extra;
		while (counter < length) {
			value = string.charCodeAt(counter++);
			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
				// high surrogate, and there is a next character
				extra = string.charCodeAt(counter++);
				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
				} else {
					// unmatched surrogate; only append this code unit, in case the next
					// code unit is the high surrogate of a surrogate pair
					output.push(value);
					counter--;
				}
			} else {
				output.push(value);
			}
		}
		return output;
	}

	// Taken from https://mths.be/punycode
	function ucs2encode(array) {
		var length = array.length;
		var index = -1;
		var value;
		var output = '';
		while (++index < length) {
			value = array[index];
			if (value > 0xFFFF) {
				value -= 0x10000;
				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
				value = 0xDC00 | value & 0x3FF;
			}
			output += stringFromCharCode(value);
		}
		return output;
	}

	function checkScalarValue(codePoint) {
		if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
			throw Error(
				'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
				' is not a scalar value'
			);
		}
	}
	/*--------------------------------------------------------------------------*/

	function createByte(codePoint, shift) {
		return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
	}

	function encodeCodePoint(codePoint) {
		if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
			return stringFromCharCode(codePoint);
		}
		var symbol = '';
		if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
			symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
		}
		else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
			checkScalarValue(codePoint);
			symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
			symbol += createByte(codePoint, 6);
		}
		else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
			symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
			symbol += createByte(codePoint, 12);
			symbol += createByte(codePoint, 6);
		}
		symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
		return symbol;
	}

	function utf8encode(string) {
		var codePoints = ucs2decode(string);
		var length = codePoints.length;
		var index = -1;
		var codePoint;
		var byteString = '';
		while (++index < length) {
			codePoint = codePoints[index];
			byteString += encodeCodePoint(codePoint);
		}
		return byteString;
	}

	/*--------------------------------------------------------------------------*/

	function readContinuationByte() {
		if (byteIndex >= byteCount) {
			throw Error('Invalid byte index');
		}

		var continuationByte = byteArray[byteIndex] & 0xFF;
		byteIndex++;

		if ((continuationByte & 0xC0) == 0x80) {
			return continuationByte & 0x3F;
		}

		// If we end up here, it’s not a continuation byte
		throw Error('Invalid continuation byte');
	}

	function decodeSymbol() {
		var byte1;
		var byte2;
		var byte3;
		var byte4;
		var codePoint;

		if (byteIndex > byteCount) {
			throw Error('Invalid byte index');
		}

		if (byteIndex == byteCount) {
			return false;
		}

		// Read first byte
		byte1 = byteArray[byteIndex] & 0xFF;
		byteIndex++;

		// 1-byte sequence (no continuation bytes)
		if ((byte1 & 0x80) == 0) {
			return byte1;
		}

		// 2-byte sequence
		if ((byte1 & 0xE0) == 0xC0) {
			var byte2 = readContinuationByte();
			codePoint = ((byte1 & 0x1F) << 6) | byte2;
			if (codePoint >= 0x80) {
				return codePoint;
			} else {
				throw Error('Invalid continuation byte');
			}
		}

		// 3-byte sequence (may include unpaired surrogates)
		if ((byte1 & 0xF0) == 0xE0) {
			byte2 = readContinuationByte();
			byte3 = readContinuationByte();
			codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
			if (codePoint >= 0x0800) {
				checkScalarValue(codePoint);
				return codePoint;
			} else {
				throw Error('Invalid continuation byte');
			}
		}

		// 4-byte sequence
		if ((byte1 & 0xF8) == 0xF0) {
			byte2 = readContinuationByte();
			byte3 = readContinuationByte();
			byte4 = readContinuationByte();
			codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
				(byte3 << 0x06) | byte4;
			if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
				return codePoint;
			}
		}

		throw Error('Invalid UTF-8 detected');
	}

	var byteArray;
	var byteCount;
	var byteIndex;
	function utf8decode(byteString) {
		byteArray = ucs2decode(byteString);
		byteCount = byteArray.length;
		byteIndex = 0;
		var codePoints = [];
		var tmp;
		while ((tmp = decodeSymbol()) !== false) {
			codePoints.push(tmp);
		}
		return ucs2encode(codePoints);
	}

	/*--------------------------------------------------------------------------*/

	var utf8 = {
		'version': '2.1.1',
		'encode': utf8encode,
		'decode': utf8decode
	};

	// Some AMD build optimizers, like r.js, check for specific condition patterns
	// like the following:
	if (
		typeof define == 'function' &&
		typeof define.amd == 'object' &&
		define.amd
	) {
		define(function() {
			return utf8;
		});
	}	else if (freeExports && !freeExports.nodeType) {
		if (freeModule) { // in Node.js or RingoJS v0.8.0+
			freeModule.exports = utf8;
		} else { // in Narwhal or RingoJS v0.7.0-
			var object = {};
			var hasOwnProperty = object.hasOwnProperty;
			for (var key in utf8) {
				hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
			}
		}
	} else { // in Rhino or a web browser
		root.utf8 = utf8;
	}

}(this));
<commit_msg>Remove redundant `var` declaration<commit_after>/*! https://mths.be/utf8js v2.1.1 by @mathias */
;(function(root) {

	// Detect free variables `exports`
	var freeExports = typeof exports == 'object' && exports;

	// Detect free variable `module`
	var freeModule = typeof module == 'object' && module &&
		module.exports == freeExports && module;

	// Detect free variable `global`, from Node.js or Browserified code,
	// and use it as `root`
	var freeGlobal = typeof global == 'object' && global;
	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
		root = freeGlobal;
	}

	/*--------------------------------------------------------------------------*/

	var stringFromCharCode = String.fromCharCode;

	// Taken from https://mths.be/punycode
	function ucs2decode(string) {
		var output = [];
		var counter = 0;
		var length = string.length;
		var value;
		var extra;
		while (counter < length) {
			value = string.charCodeAt(counter++);
			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
				// high surrogate, and there is a next character
				extra = string.charCodeAt(counter++);
				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
				} else {
					// unmatched surrogate; only append this code unit, in case the next
					// code unit is the high surrogate of a surrogate pair
					output.push(value);
					counter--;
				}
			} else {
				output.push(value);
			}
		}
		return output;
	}

	// Taken from https://mths.be/punycode
	function ucs2encode(array) {
		var length = array.length;
		var index = -1;
		var value;
		var output = '';
		while (++index < length) {
			value = array[index];
			if (value > 0xFFFF) {
				value -= 0x10000;
				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
				value = 0xDC00 | value & 0x3FF;
			}
			output += stringFromCharCode(value);
		}
		return output;
	}

	function checkScalarValue(codePoint) {
		if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
			throw Error(
				'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
				' is not a scalar value'
			);
		}
	}
	/*--------------------------------------------------------------------------*/

	function createByte(codePoint, shift) {
		return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
	}

	function encodeCodePoint(codePoint) {
		if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
			return stringFromCharCode(codePoint);
		}
		var symbol = '';
		if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
			symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
		}
		else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
			checkScalarValue(codePoint);
			symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
			symbol += createByte(codePoint, 6);
		}
		else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
			symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
			symbol += createByte(codePoint, 12);
			symbol += createByte(codePoint, 6);
		}
		symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
		return symbol;
	}

	function utf8encode(string) {
		var codePoints = ucs2decode(string);
		var length = codePoints.length;
		var index = -1;
		var codePoint;
		var byteString = '';
		while (++index < length) {
			codePoint = codePoints[index];
			byteString += encodeCodePoint(codePoint);
		}
		return byteString;
	}

	/*--------------------------------------------------------------------------*/

	function readContinuationByte() {
		if (byteIndex >= byteCount) {
			throw Error('Invalid byte index');
		}

		var continuationByte = byteArray[byteIndex] & 0xFF;
		byteIndex++;

		if ((continuationByte & 0xC0) == 0x80) {
			return continuationByte & 0x3F;
		}

		// If we end up here, it’s not a continuation byte
		throw Error('Invalid continuation byte');
	}

	function decodeSymbol() {
		var byte1;
		var byte2;
		var byte3;
		var byte4;
		var codePoint;

		if (byteIndex > byteCount) {
			throw Error('Invalid byte index');
		}

		if (byteIndex == byteCount) {
			return false;
		}

		// Read first byte
		byte1 = byteArray[byteIndex] & 0xFF;
		byteIndex++;

		// 1-byte sequence (no continuation bytes)
		if ((byte1 & 0x80) == 0) {
			return byte1;
		}

		// 2-byte sequence
		if ((byte1 & 0xE0) == 0xC0) {
			byte2 = readContinuationByte();
			codePoint = ((byte1 & 0x1F) << 6) | byte2;
			if (codePoint >= 0x80) {
				return codePoint;
			} else {
				throw Error('Invalid continuation byte');
			}
		}

		// 3-byte sequence (may include unpaired surrogates)
		if ((byte1 & 0xF0) == 0xE0) {
			byte2 = readContinuationByte();
			byte3 = readContinuationByte();
			codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
			if (codePoint >= 0x0800) {
				checkScalarValue(codePoint);
				return codePoint;
			} else {
				throw Error('Invalid continuation byte');
			}
		}

		// 4-byte sequence
		if ((byte1 & 0xF8) == 0xF0) {
			byte2 = readContinuationByte();
			byte3 = readContinuationByte();
			byte4 = readContinuationByte();
			codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
				(byte3 << 0x06) | byte4;
			if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
				return codePoint;
			}
		}

		throw Error('Invalid UTF-8 detected');
	}

	var byteArray;
	var byteCount;
	var byteIndex;
	function utf8decode(byteString) {
		byteArray = ucs2decode(byteString);
		byteCount = byteArray.length;
		byteIndex = 0;
		var codePoints = [];
		var tmp;
		while ((tmp = decodeSymbol()) !== false) {
			codePoints.push(tmp);
		}
		return ucs2encode(codePoints);
	}

	/*--------------------------------------------------------------------------*/

	var utf8 = {
		'version': '2.1.1',
		'encode': utf8encode,
		'decode': utf8decode
	};

	// Some AMD build optimizers, like r.js, check for specific condition patterns
	// like the following:
	if (
		typeof define == 'function' &&
		typeof define.amd == 'object' &&
		define.amd
	) {
		define(function() {
			return utf8;
		});
	}	else if (freeExports && !freeExports.nodeType) {
		if (freeModule) { // in Node.js or RingoJS v0.8.0+
			freeModule.exports = utf8;
		} else { // in Narwhal or RingoJS v0.7.0-
			var object = {};
			var hasOwnProperty = object.hasOwnProperty;
			for (var key in utf8) {
				hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
			}
		}
	} else { // in Rhino or a web browser
		root.utf8 = utf8;
	}

}(this));
<|endoftext|>


<commit_before>(function() {
  /*
  * Generate RFC4122 (v1 and v4) UUIDs
  *
  * Documentation at https://github.com/broofa/node-uuid
  */

  // Use node.js Buffer class if available, otherwise use the Array class
  var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array;

  // Buffer used for generating string uuids
  var _buf = new BufferClass(16);

  // Cache number <-> hex string for octet values
  var toString = [];
  var toNumber = {};
  for (var i = 0; i < 256; i++) {
    toString[i] = (i + 0x100).toString(16).substr(1);
    toNumber[toString[i]] = i;
  }

  function parse(s) {
    var buf = new BufferClass(16);
    var i = 0;
    s.toLowerCase().replace(/[0-9a-f][0-9a-f]/g, function(octet) {
      buf[i++] = toNumber[octet];
    });
    return buf;
  }

  function unparse(buf) {
    var tos = toString, b = buf;
    return tos[b[0]] + tos[b[1]] + tos[b[2]] + tos[b[3]] + '-' +
           tos[b[4]] + tos[b[5]] + '-' +
           tos[b[6]] + tos[b[7]] + '-' +
           tos[b[8]] + tos[b[9]] + '-' +
           tos[b[10]] + tos[b[11]] + tos[b[12]] +
           tos[b[13]] + tos[b[14]] + tos[b[15]];
  }

  var ff = 0xff;

  // Feature detect for the WHATWG crypto API. See
  // http://wiki.whatwg.org/wiki/Crypto
  var useCrypto = this.crypto && crypto.getRandomValues;
  var rnds = useCrypto ? new Uint32Array(4) : new Array(4);

  // Inspired by https://github.com/LiosK/UUID.js
  // and http://docs.python.org/library/uuid.html

  // Generate a node value for this instance. Use a randomly generated node
  // instead of a mac address. RFC suggests generating a 47 bit random integer,
  // but we're limited to 32 bit in js, so we just use two 32 bit.
  if (useCrypto) {
    crypto.getRandomValues(rnds);
  } else {
    rnds[0] = Math.random() * 0x100000000;
    rnds[1] = Math.random() * 0x100000000;
  }
  var node = [
    rnds[0] & ff | 0x01, // Set multicast bit, see 4.1.6 and 4.5
    rnds[0]>>>8 & ff,
    rnds[0]>>>16 & ff,
    rnds[0]>>>24 & ff,
    rnds[1] & ff,
    rnds[1]>>>8 & ff
  ];

  // Used to track time-reversals for updating the clock_seq
  var last = new Date().getTime();
  // clock_seq
  var cs = false;

  function v1(fmt, buf, offset) {
    var b = fmt != 'binary' ? _buf : (buf ? buf : new BufferClass(16));
    var i = buf && offset || 0;

    // Timestamp, see 4.1.4
    // 12219292800000 is the number of milliseconds between
    // UUID epoch 1582-10-15 00:00:00 and UNIX epoch.
    var now = (new Date().getTime());
    var timestamp = now + 12219292800000;
    var tl = ((timestamp & 0xfffffff) * 10000) % 0x100000000;
    var tmh = ((timestamp / 0x100000000) * 10000) & 0xfffffff;
    var tm = tmh & 0xffff;
    var th = tmh >> 16;
    var thav = (th & 0xfff) | 0x1000; // Set version, see 4.1.3

    // Clock sequence, see 4.1.5.
    if (now <= last || cs === false) { // check for time-reversal and reset cs
      // Use 14 bit random unsigned integer, see 4.2.2.
      if (useCrypto) {
        crypto.getRandomValues(rnds);
      } else {
        rnds[0] = Math.random()*0x100000000;
      }
      cs = rnds[0] & 0x3fff; // Cut down 32 bit random integer to 14 bit
    } else {
      cs++;
    }
    last = now;
    var csl = cs & 0xff;
    var cshar = (cs >>> 8) | 0x80; // Set the variant, see 4.2.2

    // time_low
    b[i++] = tl>>>24 & ff;
    b[i++] = tl>>>16 & ff;
    b[i++] = tl>>>8 & ff;
    b[i++] = tl & ff;

    // time_mid
    b[i++] = tm>>>8 & ff;
    b[i++] = tm & ff;

    // time_high_and_version
    b[i++] = thav>>>8 & ff;
    b[i++] = thav & ff;

    // clock_seq_hi_and_reserved
    b[i++] = cshar;

    // clock_seq_low
    b[i++] = csl;

    // node
    var n = 0;
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];

    return fmt === undefined ? unparse(b) : b;
  }

  function v4(fmt, buf, offset) {
    var b = fmt != 'binary' ? _buf : (buf ? buf : new BufferClass(16));
    var i = buf && offset || 0;

    if (useCrypto) {
      crypto.getRandomValues(rnds);
    } else {
      rnds[0] = Math.random()*0x100000000;
      rnds[1] = Math.random()*0x100000000;
      rnds[2] = Math.random()*0x100000000;
      rnds[3] = Math.random()*0x100000000;
    }

    var r = rnds[0];
    b[i++] = r & ff;
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & ff;
    b[i++] = r>>>24 & ff;
    r = rnds[1];
    b[i++] = r & ff;
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & 0x0f | 0x40; // See RFC4122 sect. 4.1.3
    b[i++] = r>>>24 & ff;
    r = rnds[2];
    b[i++] = r & 0x3f | 0x80; // See RFC4122 sect. 4.4
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & ff;
    b[i++] = r>>>24 & ff;
    r = rnds[3];
    b[i++] = r & ff;
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & ff;
    b[i++] = r>>>24 & ff;

    return fmt === undefined ? unparse(b) : b;
  }

  var uuid = v4;
  uuid.v1 = v1;
  uuid.v4 = v4;
  uuid.parse = parse;
  uuid.unparse = unparse;
  uuid.BufferClass = BufferClass;

  if (typeof(module) != 'undefined') {
    module.exports = uuid;
  } else {
    // In browser? Set as top-level function
    this.uuid = uuid;
  }
}());
<commit_msg>clock_seq initializiation and update fixes - Initialize clock_seq to a random value only once - If clock set backwards, increment clock_seq - Don't change otherwise Should be quite RFC4122 compliant now.<commit_after>(function() {
  /*
  * Generate RFC4122 (v1 and v4) UUIDs
  *
  * Documentation at https://github.com/broofa/node-uuid
  */

  // Use node.js Buffer class if available, otherwise use the Array class
  var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array;

  // Buffer used for generating string uuids
  var _buf = new BufferClass(16);

  // Cache number <-> hex string for octet values
  var toString = [];
  var toNumber = {};
  for (var i = 0; i < 256; i++) {
    toString[i] = (i + 0x100).toString(16).substr(1);
    toNumber[toString[i]] = i;
  }

  function parse(s) {
    var buf = new BufferClass(16);
    var i = 0;
    s.toLowerCase().replace(/[0-9a-f][0-9a-f]/g, function(octet) {
      buf[i++] = toNumber[octet];
    });
    return buf;
  }

  function unparse(buf) {
    var tos = toString, b = buf;
    return tos[b[0]] + tos[b[1]] + tos[b[2]] + tos[b[3]] + '-' +
           tos[b[4]] + tos[b[5]] + '-' +
           tos[b[6]] + tos[b[7]] + '-' +
           tos[b[8]] + tos[b[9]] + '-' +
           tos[b[10]] + tos[b[11]] + tos[b[12]] +
           tos[b[13]] + tos[b[14]] + tos[b[15]];
  }

  var ff = 0xff;

  // Feature detect for the WHATWG crypto API. See
  // http://wiki.whatwg.org/wiki/Crypto
  var useCrypto = this.crypto && crypto.getRandomValues;
  var rnds = useCrypto ? new Uint32Array(4) : new Array(4);

  // Inspired by https://github.com/LiosK/UUID.js
  // and http://docs.python.org/library/uuid.html

  if (useCrypto) {
    crypto.getRandomValues(rnds);
  } else {
    rnds[0] = Math.random() * 0x100000000;
    rnds[1] = Math.random() * 0x100000000;
    rnds[2] = Math.random() * 0x100000000;
  }

  // Generate a node value for this instance. Use a randomly generated node
  // instead of a mac address. RFC suggests generating a 47 bit random integer,
  // but we're limited to 32 bit in js, so we just use two 32 bit.
  var node = [
    rnds[0] & ff | 0x01, // Set multicast bit, see 4.1.6 and 4.5
    rnds[0]>>>8 & ff,
    rnds[0]>>>16 & ff,
    rnds[0]>>>24 & ff,
    rnds[1] & ff,
    rnds[1]>>>8 & ff
  ];

  // Used to track time-regressions for updating the clock_seq
  var last = new Date().getTime();
  // Use 14 bit random unsigned integer to initialize clock_seq, see 4.2.2.
  var cs = rnds[2] & 0x3fff; // Cut down 32 bit random integer to 14 bit
  console.log(cs);

  function v1(fmt, buf, offset) {
    var b = fmt != 'binary' ? _buf : (buf ? buf : new BufferClass(16));
    var i = buf && offset || 0;

    // Timestamp, see 4.1.4
    // 12219292800000 is the number of milliseconds between
    // UUID epoch 1582-10-15 00:00:00 and UNIX epoch.
    var now = (new Date().getTime());
    var timestamp = now + 12219292800000;
    var tl = ((timestamp & 0xfffffff) * 10000) % 0x100000000;
    var tmh = ((timestamp / 0x100000000) * 10000) & 0xfffffff;
    var tm = tmh & 0xffff;
    var th = tmh >> 16;
    var thav = (th & 0xfff) | 0x1000; // Set version, see 4.1.3

    // Increment clock_seq if clock is set backwards, see 4.1.5.
    if (now < last) {
      cs++;
    }
    last = now;
    var csl = cs & 0xff;
    var cshar = (cs >>> 8) | 0x80; // Set the variant, see 4.2.2

    // time_low
    b[i++] = tl>>>24 & ff;
    b[i++] = tl>>>16 & ff;
    b[i++] = tl>>>8 & ff;
    b[i++] = tl & ff;

    // time_mid
    b[i++] = tm>>>8 & ff;
    b[i++] = tm & ff;

    // time_high_and_version
    b[i++] = thav>>>8 & ff;
    b[i++] = thav & ff;

    // clock_seq_hi_and_reserved
    b[i++] = cshar;

    // clock_seq_low
    b[i++] = csl;

    // node
    var n = 0;
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];
    b[i++] = node[n++];

    return fmt === undefined ? unparse(b) : b;
  }

  function v4(fmt, buf, offset) {
    var b = fmt != 'binary' ? _buf : (buf ? buf : new BufferClass(16));
    var i = buf && offset || 0;

    if (useCrypto) {
      crypto.getRandomValues(rnds);
    } else {
      rnds[0] = Math.random()*0x100000000;
      rnds[1] = Math.random()*0x100000000;
      rnds[2] = Math.random()*0x100000000;
      rnds[3] = Math.random()*0x100000000;
    }

    var r = rnds[0];
    b[i++] = r & ff;
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & ff;
    b[i++] = r>>>24 & ff;
    r = rnds[1];
    b[i++] = r & ff;
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & 0x0f | 0x40; // See RFC4122 sect. 4.1.3
    b[i++] = r>>>24 & ff;
    r = rnds[2];
    b[i++] = r & 0x3f | 0x80; // See RFC4122 sect. 4.4
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & ff;
    b[i++] = r>>>24 & ff;
    r = rnds[3];
    b[i++] = r & ff;
    b[i++] = r>>>8 & ff;
    b[i++] = r>>>16 & ff;
    b[i++] = r>>>24 & ff;

    return fmt === undefined ? unparse(b) : b;
  }

  var uuid = v4;
  uuid.v1 = v1;
  uuid.v4 = v4;
  uuid.parse = parse;
  uuid.unparse = unparse;
  uuid.BufferClass = BufferClass;

  if (typeof(module) != 'undefined') {
    module.exports = uuid;
  } else {
    // In browser? Set as top-level function
    this.uuid = uuid;
  }
}());
<|endoftext|>