From 69e94a048fbf40aa80e9280fd5096499138df218 Mon Sep 17 00:00:00 2001 From: noopkat Date: Sun, 21 Jul 2019 17:49:04 +1000 Subject: [PATCH 01/94] chrome serial port WIP --- avrgirl-arduino-browser.js | 7 ++ avrgirl-arduino-node.js | 7 ++ avrgirl-arduino.js | 234 ++++++++++++++++++------------------- bin/cli.js | 2 +- lib/browser-serialport.js | 71 +++++++++++ lib/connection-browser.js | 217 ++++++++++++++++++++++++++++++++++ notes.md | 34 ++++++ package.json | 2 +- 8 files changed, 455 insertions(+), 119 deletions(-) create mode 100644 avrgirl-arduino-browser.js create mode 100644 avrgirl-arduino-node.js create mode 100644 lib/browser-serialport.js create mode 100644 lib/connection-browser.js create mode 100644 notes.md diff --git a/avrgirl-arduino-browser.js b/avrgirl-arduino-browser.js new file mode 100644 index 0000000..ffcc0d2 --- /dev/null +++ b/avrgirl-arduino-browser.js @@ -0,0 +1,7 @@ +var boards = require('./boards'); +var Connection = require('./lib/connection-browser'); +var protocols = require('./lib/protocols'); +var AvrgirlArduino = require('./avrgirl-arduino'); + +module.exports = AvrgirlArduino(boards, Connection, protocols); + diff --git a/avrgirl-arduino-node.js b/avrgirl-arduino-node.js new file mode 100644 index 0000000..38bef8d --- /dev/null +++ b/avrgirl-arduino-node.js @@ -0,0 +1,7 @@ +var boards = require('./boards'); +var Connection = require('./lib/connection'); +var protocols = require('./lib/protocols'); +var AvrgirlArduino = require('./avrgirl-arduino'); + +module.exports = AvrgirlArduino(boards, Connection, protocols); + diff --git a/avrgirl-arduino.js b/avrgirl-arduino.js index 819495b..ac84389 100644 --- a/avrgirl-arduino.js +++ b/avrgirl-arduino.js @@ -1,127 +1,127 @@ -var boards = require('./boards'); -var Connection = require('./lib/connection'); -var protocols = require('./lib/protocols'); - -/** - * Constructor - * - * @param {object} opts - options for consumer to pass in - */ -var AvrgirlArduino = function(opts) { - opts = opts || {}; - - this.options = { - debug: opts.debug || false, - board: opts.board || 'uno', - port: opts.port || '', - manualReset: opts.manualReset || false +var injectDependencies = function(boards, Connection, protocols) { + /** + * Constructor + * + * @param {object} opts - options for consumer to pass in + */ + var AvrgirlArduino = function(opts) { + opts = opts || {}; + + this.options = { + debug: opts.debug || false, + board: opts.board || 'uno', + port: opts.port || '', + manualReset: opts.manualReset || false + }; + + // this here checks for 3 conditions: + // if debug option is simply true, we want to fall back to default debug function + // if a custom debug function is passed in, we want to assign debug to be that + // if debug option is false, then run debug as a no-op + if (this.options.debug === true) { + this.debug = console.log.bind(console); + } else if (typeof this.options.debug === 'function') { + this.debug = this.options.debug; + } else { + this.debug = function() {}; + } + + if (typeof this.options.board === 'string') { + this.options.board = boards[this.options.board]; + } else if (typeof this.options.board === 'object') { + this.options.board = this.options.board; + } + + if (this.options.board && !this.options.board.manualReset) { + this.options.board.manualReset = this.options.manualReset; + } + + this.connection = new Connection(this.options); + + if (this.options.board) { + var Protocol = protocols[this.options.board.protocol] || function() {}; + + this.protocol = new Protocol({ + board: this.options.board, + connection: this.connection, + debug: this.debug + }); + } }; - // this here checks for 3 conditions: - // if debug option is simply true, we want to fall back to default debug function - // if a custom debug function is passed in, we want to assign debug to be that - // if debug option is false, then run debug as a no-op - if (this.options.debug === true) { - this.debug = console.log.bind(console); - } else if (typeof this.options.debug === 'function') { - this.debug = this.options.debug; - } else { - this.debug = function() {}; - } - - if (typeof this.options.board === 'string') { - this.options.board = boards[this.options.board]; - } else if (typeof this.options.board === 'object') { - this.options.board = this.options.board; - } - - if (this.options.board && !this.options.board.manualReset) { - this.options.board.manualReset = this.options.manualReset; - } - - this.connection = new Connection(this.options); - - if (this.options.board) { - var Protocol = protocols[this.options.board.protocol] || function() {}; - - this.protocol = new Protocol({ - board: this.options.board, - connection: this.connection, - debug: this.debug - }); - } -}; - -/** - * Validates the board properties - * - * @param {function} callback - function to run upon completion/error - */ -AvrgirlArduino.prototype._validateBoard = function(callback) { - if (typeof this.options.board !== 'object') { - // cannot find a matching board in supported list - return callback(new Error('"' + this.options.board + '" is not a supported board type.')); - - } else if (!this.protocol.chip) { - // something went wrong trying to set up the protocol - var errorMsg = 'not a supported programming protocol: ' + this.options.board.protocol; - return callback(new Error(errorMsg)); - - } else if (!this.options.port && this.options.board.name === 'pro-mini') { - // when using a pro mini, a port is required in the options - return callback(new Error('using a pro-mini, please specify the port in your options.')); - - } else { - // all good - return callback(null); - } -}; + /** + * Validates the board properties + * + * @param {function} callback - function to run upon completion/error + */ + AvrgirlArduino.prototype._validateBoard = function(callback) { + if (typeof this.options.board !== 'object') { + // cannot find a matching board in supported list + return callback(new Error('"' + this.options.board + '" is not a supported board type.')); + + } else if (!this.protocol.chip) { + // something went wrong trying to set up the protocol + var errorMsg = 'not a supported programming protocol: ' + this.options.board.protocol; + return callback(new Error(errorMsg)); + + } else if (!this.options.port && this.options.board.name === 'pro-mini') { + // when using a pro mini, a port is required in the options + return callback(new Error('using a pro-mini, please specify the port in your options.')); + + } else { + // all good + return callback(null); + } + }; -/** - * Public method for flashing a hex file to the main program allocation of the Arduino - * - * @param {string} file - path to hex file for uploading - * @param {function} callback - function to run upon completion/error - */ -AvrgirlArduino.prototype.flash = function(file, callback) { - var _this = this; - - // validate board properties first - _this._validateBoard(function(error) { - if (error) { return callback(error); } - - // set up serialport connection - _this.connection._init(function(error) { + /** + * Public method for flashing a hex file to the main program allocation of the Arduino + * + * @param {string} file - path to hex file for uploading + * @param {function} callback - function to run upon completion/error + */ + AvrgirlArduino.prototype.flash = function(file, callback) { + var _this = this; + + // validate board properties first + _this._validateBoard(function(error) { if (error) { return callback(error); } - // upload file to board - _this.protocol._upload(file, callback); + // set up serialport connection + _this.connection._init(function(error) { + if (error) { return callback(error); } + + // upload file to board + _this.protocol._upload(file, callback); + }); }); - }); -}; + }; -/** - * Return a list of devices on serial ports. In addition to the output provided - * by SerialPort.list, it adds a platform independent PID in _pid - * - * @param {function} callback - function to run upon completion/error - */ -AvrgirlArduino.prototype.listPorts = AvrgirlArduino.listPorts = -AvrgirlArduino.prototype.list = AvrgirlArduino.list = function(callback) { - return Connection.prototype._listPorts(callback); -}; + /** + * Return a list of devices on serial ports. In addition to the output provided + * by SerialPort.list, it adds a platform independent PID in _pid + * + * @param {function} callback - function to run upon completion/error + */ + AvrgirlArduino.prototype.listPorts = AvrgirlArduino.listPorts = + AvrgirlArduino.prototype.list = AvrgirlArduino.list = function(callback) { + return Connection.prototype._listPorts(callback); + }; + + /** + * Static method to return the names of all known boards. + */ + AvrgirlArduino.listKnownBoards = function() { + // filter the boards to find all non-aliases + return Object.keys(boards).filter(function(name) { + // fetch the current board aliases + var aliases = boards[name].aliases; + // only allow the name if it's not an alias + return !aliases || !~aliases.indexOf(name); + }); + }; -/** - * Static method to return the names of all known boards. - */ -AvrgirlArduino.listKnownBoards = function() { - // filter the boards to find all non-aliases - return Object.keys(boards).filter(function(name) { - // fetch the current board aliases - var aliases = boards[name].aliases; - // only allow the name if it's not an alias - return !aliases || !~aliases.indexOf(name); - }); + return AvrgirlArduino; }; -module.exports = AvrgirlArduino; \ No newline at end of file +module.exports = injectDependencies; diff --git a/bin/cli.js b/bin/cli.js index 5b9707d..1a84ff9 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -var Avrgirl = require('../avrgirl-arduino'); +var Avrgirl = require('../'); var boards = require('../boards'); var parseArgs = require('minimist'); var path = require('path'); diff --git a/lib/browser-serialport.js b/lib/browser-serialport.js new file mode 100644 index 0000000..c4fdc97 --- /dev/null +++ b/lib/browser-serialport.js @@ -0,0 +1,71 @@ +class SerialPort { + constructor(options) { + this.options = options; + + this.path = this.options.path; + this.port = null; + this.writer = null; + this.reader = null; + this.baudrate = this.options.baudRate; + + // not sure what needs to go into this options object (perhaps pid / vid filters like webusb?) + var requestOptions = {}; + + navigator.serial.requestPort(requestOptions) + .then(serialPort => this.port = serialport) + .then(() => this.writer = this.port.getWriter()) + .then(() => this.reader = this.port.getReader()) + .catch(error => {throw new Error(error)}); + } + + list(callback) { + navigator.serial.getPorts() + .then((list) => callback(null, list)) + .catch((error) => callback(error)); + } + + open(callback) { + this.port.open({baudrate: this.boardrate}) + .then(() => callback(null)) + .catch((error) => callback(error)); + } + + close(callback) { + this.port.close() + .then(() => callback(null)) + .catch((error) => callback(error)); + } + + set(props, callback) { + // I'm not entirely sure the remappings below are correct + // TODO: read the serial spec to be sure + const remappedSignals = { + signals: { + dsr: props.dtr, + ri: props.rts + } + }; + + this.port.setControlSignals(remappedSignals) + .then(() => callback(null)) + .catch((error) => callback(error)); + } + + write(buffer, callback) { + this.writer.write(buffer); + return callback(null); + } + + read(callback) { + this.reader.read() + .then((buffer) => callback(null, buffer)) + .catch((error) => callback(error)); + } + + // TODO: is this correct? + flush() { + this.port.flush(); + } +} + +module.exports = SerialPort; diff --git a/lib/connection-browser.js b/lib/connection-browser.js new file mode 100644 index 0000000..68ec248 --- /dev/null +++ b/lib/connection-browser.js @@ -0,0 +1,217 @@ +var Serialport = require('./browser-serialport'); +var async = require('async'); +var awty = require('awty'); + +var Connection = function(options) { + this.options = options; + this.debug = this.options.debug ? console.log.bind(console) : function() {}; + + this.board = this.options.board; +}; + +Connection.prototype._init = function(callback) { + var _this = this; + + // check for port + if (!_this.options.port) { + // no port, auto sniff for the correct one + _this._sniffPort(function(error, port) { + if (port.length) { + // found a port, save it + _this.options.port = port[0].comName; + + _this.debug('found ' + _this.options.board.name + ' on port ' + _this.options.port); + + // set up serialport for it + _this._setUpSerial(function(error) { + return callback(error); + }); + } else { + // we didn't find the board + return callback(new Error('no Arduino ' + '\'' + _this.options.board.name + '\'' + ' found.')); + } + }); + + } else { + // when a port is manually specified + _this._setUpSerial(function(error) { + return callback(error); + }); + } +}; + +/** + * Create new serialport instance for the Arduino board, but do not immediately connect. + */ +Connection.prototype._setUpSerial = function(callback) { + this.serialPort = new Serialport(this.options.port, { + baudRate: this.board.baud, + autoOpen: false + }); + return callback(null); +}; + +/** + * Finds a list of available USB ports, and matches for the right pid + * Auto finds the correct port for the chosen Arduino + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._sniffPort = function(callback) { + var _this = this; + var pidList = _this.board.productId.map(function(id) { + return parseInt(id, 16); + }); + + _this._listPorts(function(error, ports) { + // filter for a match by product id + var portMatch = ports.filter(function(p) { + return pidList.indexOf(parseInt(p._standardPid, 16)) !== -1; + }); + + return callback(null, portMatch); + }); +}; + +/** + * Sets the DTR/RTS lines to either true or false + * + * @param {boolean} bool - value to set DTR and RTS to + * @param {number} timeout - number in milliseconds to delay after + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._setDTR = function(bool, timeout, callback) { + var _this = this; + var props = { + rts: bool, + dtr: bool + }; + + _this.serialPort.set(props, function(error) { + if (error) { return callback(error); } + + setTimeout(function() { + callback(error); + }, timeout); + }); +}; + +/** + * Checks the list of ports 4 times for a device to show up + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._pollForPort = function(callback) { + var _this = this; + + var poll = awty(function(next) { + var found = false; + + // try to sniff port instead (for port hopping devices) + _this._sniffPort(function(error, port) { + if (port.length) { + // found a port, save it + _this.options.port = port[0].comName; + found = true; + } + + next(found); + }); + }); + + poll.every(100).ask(15); + + poll(function(foundPort) { + if (foundPort) { + _this.debug('found port on', _this.options.port); + // set up serialport for it + _this._setUpSerial(function(error) { + return callback(error); + }); + } else { + // we also could not find the device on auto sniff + return callback(new Error('could not reconnect after resetting board.')); + } + }); +}; + +Connection.prototype._pollForOpen = function(callback) { + var _this = this; + + var poll = awty(function(next) { + _this.serialPort.open(function(error) { + next(!error); + }); + }); + + poll.every(200).ask(10); + + poll(function(isOpen) { + var error; + if (!isOpen) { + error = new Error('could not open board on ' + _this.serialPort.path); + } + + callback(error); + }); +}; + +/** + * Pulse the DTR/RTS lines low then high + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._cycleDTR = function(callback) { + var _this = this; + + async.series([ + _this._setDTR.bind(_this, true, 250), + _this._setDTR.bind(_this, false, 50) + ], + function(error) { + return callback(error); + }); + +}; + +/** + * Return a list of devices on serial ports. In addition to the output provided + * by SerialPort.list, it adds a platform independent PID in _pid + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._listPorts = function(callback) { + var foundPorts = []; + + // list all available ports + Serialport.list(function(err, ports) { + if (err) { return callback(err); } + + // iterate through ports + for (var i = 0; i < ports.length; i += 1) { + var pid; + + // are we on windows or unix? + // TODO: this can be simplified as Chrome will likely give us a consistent set of props across each OS + if (ports[i].productId) { + pid = ports[i].productId; + } else if (ports[i].pnpId) { + try { + pid = '0x' + /PID_\d*/.exec(ports[i].pnpId)[0].substr(4); + } catch (err) { + pid = ''; + } + } else { + pid = ''; + } + + // TODO: find out if returned ports are immutable + ports[i]._standardPid = pid; + foundPorts.push(ports[i]); + } + + return callback(null, foundPorts); + }); +}; + +module.exports = Connection; diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..d860b65 --- /dev/null +++ b/notes.md @@ -0,0 +1,34 @@ +# Chrome Serial support for Avrgirl Arduino + +## methods and properties needed for direct mappings / translation interface + +### constructor / static ++ `new SerialPort()` -> `navigator.serial.requestPort` ++ `SerialPort.list` -> `navigator.serial.getPorts` + +### instance ++ `serialPort.open` -> `serialPort.open` ++ `serialPort.path` -> manually set after user gesture and user permission granted? I don't see it in the port info object ++ `serialPort.close` -> `serialPort.close` ++ `serialPort.set` -> `serialPort.setControlSignals` ++ `serialPort.write` -> `serialPort.writeable.getWriter().write` ++ `serialPort.read` -> `serialPort.readable.getReader().read` ++ `serialPort.flush` -> `serialPort.flush` + +### events ++ error ++ close ++ open + +**Note:** this list is not exhaustive of node serialport but these are the minimum requirements in order to bootstrap Avrgirl Arduino + +## questions ++ what should the default buffer size be for writing? Although in Avrgirl we can set this to the pageSize + amount of control bytes needed for opcodes ++ should the browser serialport library shim be written in typescript? (probably) ++ how are the pid and vid properties extracted? Assumption is that they're included in the properties of `getPorts` results though I don't see it in the fake mock that Reilly wrote ++ how can a static method be declared in an ES6 class declaration? I forget right now and I don't have internet for a week to look it up ++ should a more modern interface of promises be an option for the library shim while remaining compatible with existing callback implementation? ++ should the bundler be changed from browserify to webpack? graceful-fs would need to be swapped out for regular fs if so ++ do the events all match up to equivalencies? ++ perhaps the serialPort.path needs to be the id of the serial device instance? How do we reconnect after a reset of the device? + diff --git a/package.json b/package.json index 0ce96d4..ebbf316 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "3.0.2", "description": "A NodeJS library for flashing compiled sketch files to Arduino microcontroller boards.", "bin": "./bin/cli.js", - "main": "avrgirl-arduino.js", + "main": "avrgirl-arduino-node.js", "scripts": { "test": "gulp test", "cover": "istanbul cover ./tests/*.spec.js && istanbul-coveralls" From 0a5c762666672a3b1b525b1a7da5c84ff482d28a Mon Sep 17 00:00:00 2001 From: Patrick Weingaertner Date: Mon, 12 Aug 2019 23:35:16 +0200 Subject: [PATCH 02/94] add product pages --- boards.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/boards.js b/boards.js index 11c0f40..b89d3d8 100644 --- a/boards.js +++ b/boards.js @@ -7,6 +7,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0x0043', '0x7523', '0x0001', '0xea60'], + productPage: 'https://store.arduino.cc/arduino-uno-rev3', protocol: 'stk500v1' }, { @@ -14,6 +15,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x0037', '0x8037', '0x0036', '0x0237'], + productPage: 'https://store.arduino.cc/arduino-micro', protocol: 'avr109' }, { @@ -21,6 +23,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x0036', '0x8037', '0x8036'], + productPage: 'https://www.kickstarter.com/projects/1265095814/imuduino-wireless-3d-motion-html-js-apps-arduino-p?lang=de', protocol: 'avr109' }, { @@ -28,6 +31,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x0036', '0x8036', '0x800c'], + productPage: 'https://store.arduino.cc/leonardo', protocol: 'avr109' }, { @@ -35,6 +39,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x0036', '0x8036', '0x800c'], + productPage: 'https://arduboy.com/', protocol: 'avr109' }, { @@ -42,6 +47,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x800c', '0x000c'], + productPage: 'https://www.adafruit.com/feather', protocol: 'avr109' }, { @@ -49,6 +55,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x0036', '0x8036'], + productPage: 'https://littlebits.com/collections/bits-and-accessories/products/arduino-bit', protocol: 'avr109' }, { @@ -56,6 +63,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x2404'], + productPage: 'https://redbear.cc/product/retired/blend-micro.html', protocol: 'avr109' }, { @@ -66,6 +74,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0x6001', '0x7523'], + productPage: 'https://web.archive.org/web/20150813095112/https://www.arduino.cc/en/Main/ArduinoBoardNano', protocol: 'stk500v1' }, { @@ -76,6 +85,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0x6001', '0x7523'], + productPage: 'https://store.arduino.cc/arduino-nano', protocol: 'stk500v1' }, { @@ -86,6 +96,7 @@ var boards = [ numPages: 128, timeout: 400, productId: ['0x6001'], + productPage: 'https://www.arduino.cc/en/Main/arduinoBoardDuemilanove', protocol: 'stk500v1' }, { @@ -96,6 +107,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0x6001'], + productPage: 'https://www.arduino.cc/en/Main/arduinoBoardDuemilanove', protocol: 'stk500v1' }, // the alias is here because of an accidental naming change of the tinyduino @@ -108,6 +120,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0x6015'], + productPage: 'https://tinycircuits.com/pages/tinyduino-overview', protocol: 'stk500v1', aliases: ['tinduino'] }, @@ -126,6 +139,7 @@ var boards = [ pollValue:0x53, pollIndex:0x03, productId: ['0x0042', '0x6001', '0x0010', '0x7523'], + productPage: 'https://store.arduino.cc/mega-2560-r3', protocol: 'stk500v2' }, { @@ -143,6 +157,7 @@ var boards = [ pollValue:0x53, pollIndex:0x03, productId: ['0x0044', '0x6001', '0x003F'], + productPage: 'https://store.arduino.cc/arduino-mega-adk-rev3', protocol: 'stk500v2' }, { @@ -150,6 +165,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x9206', '0x9205'], + productPage: 'https://www.sparkfun.com/products/12640', protocol: 'avr109' }, { @@ -159,6 +175,7 @@ var boards = [ pageSize: 128, numPages: 256, timeout: 400, + productPage: 'https://store.arduino.cc/arduino-pro-mini', protocol: 'stk500v1' }, { @@ -166,6 +183,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x516d', '0x514d'], + productPage: 'https://www.sparkfun.com/products/13614', protocol: 'avr109' }, { @@ -183,6 +201,7 @@ var boards = [ pollValue:0x53, pollIndex:0x03, productId: ['0x6051'], + productPage: 'https://www.mouser.de/new/crowd-supply/crowd-supply-pinoccio-microcontroller/', protocol: 'stk500v2' }, { @@ -190,6 +209,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x9207', '0x9208', '0x1B4F'], + productPage: 'https://www.sparkfun.com/products/12049', protocol: 'avr109' }, { @@ -197,6 +217,7 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x0041', '0x8041'], + productPage: 'https://store.arduino.cc/arduino-yun', protocol: 'avr109' }, { @@ -204,13 +225,15 @@ var boards = [ baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x003C', '0x803C'], + productPage: 'https://store.arduino.cc/arduino-esplora', protocol: 'avr109' - }, + }, { name: 'circuit-playground-classic', baud: 57600, signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), productId: ['0x0011', '0x8011'], + productPage: 'https://www.adafruit.com/product/3000', protocol: 'avr109' }, /** BQ - Arduino Based Boards. Used in Bitbloq -> bitbloq.bq.com and Arduino IDE*/ @@ -222,6 +245,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0xEA60'], + productPage: 'https://store-de.bq.com/de/zum-kit-junior', protocol: 'stk500v1' }, { @@ -232,6 +256,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0xEA60'], + productPage: 'https://www.bq.com/de/zum-core-2-0', protocol: 'stk500v1' }, { @@ -242,10 +267,11 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0x6001', '0x7523'], + productPage: 'http://diwo.bq.com/zum-bt-328-especificaciones-tecnicas/', protocol: 'stk500v1' }, /** END OF BQ - Arduino Based Boards. Used in Bitbloq -> bitbloq.bq.com and Arduino IDE*/ - + /** START OF Spark Concepts Boards - Arduino Based CNC Controller but uses Atmega328pb (Note 'pb' not 'p' = different signature) https://github.com/Spark-Concepts/xPro-V4 */ { name: 'xprov4', @@ -255,6 +281,7 @@ var boards = [ numPages: 256, timeout: 400, productId: ['0x0043', '0x7523', '0x0001', '0xea60'], + productPage: 'http://www.spark-concepts.com/cnc-xpro-v4-controller/', protocol: 'stk500v1' }, ]; From e4deb8805aaa6c96f2c7abb8c946b6046594b5de Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Tue, 20 Aug 2019 16:46:28 -0700 Subject: [PATCH 03/94] working for firmata on an uno --- lib/browser-serialport.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/browser-serialport.js b/lib/browser-serialport.js index c4fdc97..ea48e95 100644 --- a/lib/browser-serialport.js +++ b/lib/browser-serialport.js @@ -1,6 +1,9 @@ -class SerialPort { +const { EventEmitter } = require('events'); + +class SerialPort extends EventEmitter { constructor(options) { - this.options = options; + super(options); + this.options = options || {}; this.path = this.options.path; this.port = null; @@ -12,9 +15,28 @@ class SerialPort { var requestOptions = {}; navigator.serial.requestPort(requestOptions) - .then(serialPort => this.port = serialport) - .then(() => this.writer = this.port.getWriter()) - .then(() => this.reader = this.port.getReader()) + .then(serialPort => { + this.port = serialPort; + return this.port.open({ baudrate: this.baudrate || 57600 }); + }) + .then(() => this.writer = this.port.writable.getWriter()) + .then(() => this.reader = this.port.readable.getReader()) + .then(async () => { + this.emit('open'); + while (this.port.readable) { + try { + while (true) { + const { value, done } = await this.reader.read(); + this.emit('data', value); + if (done) { + break; + } + } + } catch (e) { + term.writeln(``); + } + } + }) .catch(error => {throw new Error(error)}); } From 5537c6638025f28eb231593662f0d4144e1346de Mon Sep 17 00:00:00 2001 From: noopkat Date: Sun, 21 Jul 2019 17:49:04 +1000 Subject: [PATCH 04/94] chrome serial port WIP --- avrgirl-arduino-browser.js | 7 ++ avrgirl-arduino-node.js | 7 ++ avrgirl-arduino.js | 234 ++++++++++++++++++------------------- bin/cli.js | 2 +- lib/browser-serialport.js | 71 +++++++++++ lib/connection-browser.js | 217 ++++++++++++++++++++++++++++++++++ notes.md | 34 ++++++ package.json | 2 +- 8 files changed, 455 insertions(+), 119 deletions(-) create mode 100644 avrgirl-arduino-browser.js create mode 100644 avrgirl-arduino-node.js create mode 100644 lib/browser-serialport.js create mode 100644 lib/connection-browser.js create mode 100644 notes.md diff --git a/avrgirl-arduino-browser.js b/avrgirl-arduino-browser.js new file mode 100644 index 0000000..ffcc0d2 --- /dev/null +++ b/avrgirl-arduino-browser.js @@ -0,0 +1,7 @@ +var boards = require('./boards'); +var Connection = require('./lib/connection-browser'); +var protocols = require('./lib/protocols'); +var AvrgirlArduino = require('./avrgirl-arduino'); + +module.exports = AvrgirlArduino(boards, Connection, protocols); + diff --git a/avrgirl-arduino-node.js b/avrgirl-arduino-node.js new file mode 100644 index 0000000..38bef8d --- /dev/null +++ b/avrgirl-arduino-node.js @@ -0,0 +1,7 @@ +var boards = require('./boards'); +var Connection = require('./lib/connection'); +var protocols = require('./lib/protocols'); +var AvrgirlArduino = require('./avrgirl-arduino'); + +module.exports = AvrgirlArduino(boards, Connection, protocols); + diff --git a/avrgirl-arduino.js b/avrgirl-arduino.js index 819495b..ac84389 100644 --- a/avrgirl-arduino.js +++ b/avrgirl-arduino.js @@ -1,127 +1,127 @@ -var boards = require('./boards'); -var Connection = require('./lib/connection'); -var protocols = require('./lib/protocols'); - -/** - * Constructor - * - * @param {object} opts - options for consumer to pass in - */ -var AvrgirlArduino = function(opts) { - opts = opts || {}; - - this.options = { - debug: opts.debug || false, - board: opts.board || 'uno', - port: opts.port || '', - manualReset: opts.manualReset || false +var injectDependencies = function(boards, Connection, protocols) { + /** + * Constructor + * + * @param {object} opts - options for consumer to pass in + */ + var AvrgirlArduino = function(opts) { + opts = opts || {}; + + this.options = { + debug: opts.debug || false, + board: opts.board || 'uno', + port: opts.port || '', + manualReset: opts.manualReset || false + }; + + // this here checks for 3 conditions: + // if debug option is simply true, we want to fall back to default debug function + // if a custom debug function is passed in, we want to assign debug to be that + // if debug option is false, then run debug as a no-op + if (this.options.debug === true) { + this.debug = console.log.bind(console); + } else if (typeof this.options.debug === 'function') { + this.debug = this.options.debug; + } else { + this.debug = function() {}; + } + + if (typeof this.options.board === 'string') { + this.options.board = boards[this.options.board]; + } else if (typeof this.options.board === 'object') { + this.options.board = this.options.board; + } + + if (this.options.board && !this.options.board.manualReset) { + this.options.board.manualReset = this.options.manualReset; + } + + this.connection = new Connection(this.options); + + if (this.options.board) { + var Protocol = protocols[this.options.board.protocol] || function() {}; + + this.protocol = new Protocol({ + board: this.options.board, + connection: this.connection, + debug: this.debug + }); + } }; - // this here checks for 3 conditions: - // if debug option is simply true, we want to fall back to default debug function - // if a custom debug function is passed in, we want to assign debug to be that - // if debug option is false, then run debug as a no-op - if (this.options.debug === true) { - this.debug = console.log.bind(console); - } else if (typeof this.options.debug === 'function') { - this.debug = this.options.debug; - } else { - this.debug = function() {}; - } - - if (typeof this.options.board === 'string') { - this.options.board = boards[this.options.board]; - } else if (typeof this.options.board === 'object') { - this.options.board = this.options.board; - } - - if (this.options.board && !this.options.board.manualReset) { - this.options.board.manualReset = this.options.manualReset; - } - - this.connection = new Connection(this.options); - - if (this.options.board) { - var Protocol = protocols[this.options.board.protocol] || function() {}; - - this.protocol = new Protocol({ - board: this.options.board, - connection: this.connection, - debug: this.debug - }); - } -}; - -/** - * Validates the board properties - * - * @param {function} callback - function to run upon completion/error - */ -AvrgirlArduino.prototype._validateBoard = function(callback) { - if (typeof this.options.board !== 'object') { - // cannot find a matching board in supported list - return callback(new Error('"' + this.options.board + '" is not a supported board type.')); - - } else if (!this.protocol.chip) { - // something went wrong trying to set up the protocol - var errorMsg = 'not a supported programming protocol: ' + this.options.board.protocol; - return callback(new Error(errorMsg)); - - } else if (!this.options.port && this.options.board.name === 'pro-mini') { - // when using a pro mini, a port is required in the options - return callback(new Error('using a pro-mini, please specify the port in your options.')); - - } else { - // all good - return callback(null); - } -}; + /** + * Validates the board properties + * + * @param {function} callback - function to run upon completion/error + */ + AvrgirlArduino.prototype._validateBoard = function(callback) { + if (typeof this.options.board !== 'object') { + // cannot find a matching board in supported list + return callback(new Error('"' + this.options.board + '" is not a supported board type.')); + + } else if (!this.protocol.chip) { + // something went wrong trying to set up the protocol + var errorMsg = 'not a supported programming protocol: ' + this.options.board.protocol; + return callback(new Error(errorMsg)); + + } else if (!this.options.port && this.options.board.name === 'pro-mini') { + // when using a pro mini, a port is required in the options + return callback(new Error('using a pro-mini, please specify the port in your options.')); + + } else { + // all good + return callback(null); + } + }; -/** - * Public method for flashing a hex file to the main program allocation of the Arduino - * - * @param {string} file - path to hex file for uploading - * @param {function} callback - function to run upon completion/error - */ -AvrgirlArduino.prototype.flash = function(file, callback) { - var _this = this; - - // validate board properties first - _this._validateBoard(function(error) { - if (error) { return callback(error); } - - // set up serialport connection - _this.connection._init(function(error) { + /** + * Public method for flashing a hex file to the main program allocation of the Arduino + * + * @param {string} file - path to hex file for uploading + * @param {function} callback - function to run upon completion/error + */ + AvrgirlArduino.prototype.flash = function(file, callback) { + var _this = this; + + // validate board properties first + _this._validateBoard(function(error) { if (error) { return callback(error); } - // upload file to board - _this.protocol._upload(file, callback); + // set up serialport connection + _this.connection._init(function(error) { + if (error) { return callback(error); } + + // upload file to board + _this.protocol._upload(file, callback); + }); }); - }); -}; + }; -/** - * Return a list of devices on serial ports. In addition to the output provided - * by SerialPort.list, it adds a platform independent PID in _pid - * - * @param {function} callback - function to run upon completion/error - */ -AvrgirlArduino.prototype.listPorts = AvrgirlArduino.listPorts = -AvrgirlArduino.prototype.list = AvrgirlArduino.list = function(callback) { - return Connection.prototype._listPorts(callback); -}; + /** + * Return a list of devices on serial ports. In addition to the output provided + * by SerialPort.list, it adds a platform independent PID in _pid + * + * @param {function} callback - function to run upon completion/error + */ + AvrgirlArduino.prototype.listPorts = AvrgirlArduino.listPorts = + AvrgirlArduino.prototype.list = AvrgirlArduino.list = function(callback) { + return Connection.prototype._listPorts(callback); + }; + + /** + * Static method to return the names of all known boards. + */ + AvrgirlArduino.listKnownBoards = function() { + // filter the boards to find all non-aliases + return Object.keys(boards).filter(function(name) { + // fetch the current board aliases + var aliases = boards[name].aliases; + // only allow the name if it's not an alias + return !aliases || !~aliases.indexOf(name); + }); + }; -/** - * Static method to return the names of all known boards. - */ -AvrgirlArduino.listKnownBoards = function() { - // filter the boards to find all non-aliases - return Object.keys(boards).filter(function(name) { - // fetch the current board aliases - var aliases = boards[name].aliases; - // only allow the name if it's not an alias - return !aliases || !~aliases.indexOf(name); - }); + return AvrgirlArduino; }; -module.exports = AvrgirlArduino; \ No newline at end of file +module.exports = injectDependencies; diff --git a/bin/cli.js b/bin/cli.js index 5b9707d..1a84ff9 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -var Avrgirl = require('../avrgirl-arduino'); +var Avrgirl = require('../'); var boards = require('../boards'); var parseArgs = require('minimist'); var path = require('path'); diff --git a/lib/browser-serialport.js b/lib/browser-serialport.js new file mode 100644 index 0000000..c4fdc97 --- /dev/null +++ b/lib/browser-serialport.js @@ -0,0 +1,71 @@ +class SerialPort { + constructor(options) { + this.options = options; + + this.path = this.options.path; + this.port = null; + this.writer = null; + this.reader = null; + this.baudrate = this.options.baudRate; + + // not sure what needs to go into this options object (perhaps pid / vid filters like webusb?) + var requestOptions = {}; + + navigator.serial.requestPort(requestOptions) + .then(serialPort => this.port = serialport) + .then(() => this.writer = this.port.getWriter()) + .then(() => this.reader = this.port.getReader()) + .catch(error => {throw new Error(error)}); + } + + list(callback) { + navigator.serial.getPorts() + .then((list) => callback(null, list)) + .catch((error) => callback(error)); + } + + open(callback) { + this.port.open({baudrate: this.boardrate}) + .then(() => callback(null)) + .catch((error) => callback(error)); + } + + close(callback) { + this.port.close() + .then(() => callback(null)) + .catch((error) => callback(error)); + } + + set(props, callback) { + // I'm not entirely sure the remappings below are correct + // TODO: read the serial spec to be sure + const remappedSignals = { + signals: { + dsr: props.dtr, + ri: props.rts + } + }; + + this.port.setControlSignals(remappedSignals) + .then(() => callback(null)) + .catch((error) => callback(error)); + } + + write(buffer, callback) { + this.writer.write(buffer); + return callback(null); + } + + read(callback) { + this.reader.read() + .then((buffer) => callback(null, buffer)) + .catch((error) => callback(error)); + } + + // TODO: is this correct? + flush() { + this.port.flush(); + } +} + +module.exports = SerialPort; diff --git a/lib/connection-browser.js b/lib/connection-browser.js new file mode 100644 index 0000000..68ec248 --- /dev/null +++ b/lib/connection-browser.js @@ -0,0 +1,217 @@ +var Serialport = require('./browser-serialport'); +var async = require('async'); +var awty = require('awty'); + +var Connection = function(options) { + this.options = options; + this.debug = this.options.debug ? console.log.bind(console) : function() {}; + + this.board = this.options.board; +}; + +Connection.prototype._init = function(callback) { + var _this = this; + + // check for port + if (!_this.options.port) { + // no port, auto sniff for the correct one + _this._sniffPort(function(error, port) { + if (port.length) { + // found a port, save it + _this.options.port = port[0].comName; + + _this.debug('found ' + _this.options.board.name + ' on port ' + _this.options.port); + + // set up serialport for it + _this._setUpSerial(function(error) { + return callback(error); + }); + } else { + // we didn't find the board + return callback(new Error('no Arduino ' + '\'' + _this.options.board.name + '\'' + ' found.')); + } + }); + + } else { + // when a port is manually specified + _this._setUpSerial(function(error) { + return callback(error); + }); + } +}; + +/** + * Create new serialport instance for the Arduino board, but do not immediately connect. + */ +Connection.prototype._setUpSerial = function(callback) { + this.serialPort = new Serialport(this.options.port, { + baudRate: this.board.baud, + autoOpen: false + }); + return callback(null); +}; + +/** + * Finds a list of available USB ports, and matches for the right pid + * Auto finds the correct port for the chosen Arduino + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._sniffPort = function(callback) { + var _this = this; + var pidList = _this.board.productId.map(function(id) { + return parseInt(id, 16); + }); + + _this._listPorts(function(error, ports) { + // filter for a match by product id + var portMatch = ports.filter(function(p) { + return pidList.indexOf(parseInt(p._standardPid, 16)) !== -1; + }); + + return callback(null, portMatch); + }); +}; + +/** + * Sets the DTR/RTS lines to either true or false + * + * @param {boolean} bool - value to set DTR and RTS to + * @param {number} timeout - number in milliseconds to delay after + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._setDTR = function(bool, timeout, callback) { + var _this = this; + var props = { + rts: bool, + dtr: bool + }; + + _this.serialPort.set(props, function(error) { + if (error) { return callback(error); } + + setTimeout(function() { + callback(error); + }, timeout); + }); +}; + +/** + * Checks the list of ports 4 times for a device to show up + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._pollForPort = function(callback) { + var _this = this; + + var poll = awty(function(next) { + var found = false; + + // try to sniff port instead (for port hopping devices) + _this._sniffPort(function(error, port) { + if (port.length) { + // found a port, save it + _this.options.port = port[0].comName; + found = true; + } + + next(found); + }); + }); + + poll.every(100).ask(15); + + poll(function(foundPort) { + if (foundPort) { + _this.debug('found port on', _this.options.port); + // set up serialport for it + _this._setUpSerial(function(error) { + return callback(error); + }); + } else { + // we also could not find the device on auto sniff + return callback(new Error('could not reconnect after resetting board.')); + } + }); +}; + +Connection.prototype._pollForOpen = function(callback) { + var _this = this; + + var poll = awty(function(next) { + _this.serialPort.open(function(error) { + next(!error); + }); + }); + + poll.every(200).ask(10); + + poll(function(isOpen) { + var error; + if (!isOpen) { + error = new Error('could not open board on ' + _this.serialPort.path); + } + + callback(error); + }); +}; + +/** + * Pulse the DTR/RTS lines low then high + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._cycleDTR = function(callback) { + var _this = this; + + async.series([ + _this._setDTR.bind(_this, true, 250), + _this._setDTR.bind(_this, false, 50) + ], + function(error) { + return callback(error); + }); + +}; + +/** + * Return a list of devices on serial ports. In addition to the output provided + * by SerialPort.list, it adds a platform independent PID in _pid + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._listPorts = function(callback) { + var foundPorts = []; + + // list all available ports + Serialport.list(function(err, ports) { + if (err) { return callback(err); } + + // iterate through ports + for (var i = 0; i < ports.length; i += 1) { + var pid; + + // are we on windows or unix? + // TODO: this can be simplified as Chrome will likely give us a consistent set of props across each OS + if (ports[i].productId) { + pid = ports[i].productId; + } else if (ports[i].pnpId) { + try { + pid = '0x' + /PID_\d*/.exec(ports[i].pnpId)[0].substr(4); + } catch (err) { + pid = ''; + } + } else { + pid = ''; + } + + // TODO: find out if returned ports are immutable + ports[i]._standardPid = pid; + foundPorts.push(ports[i]); + } + + return callback(null, foundPorts); + }); +}; + +module.exports = Connection; diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..d860b65 --- /dev/null +++ b/notes.md @@ -0,0 +1,34 @@ +# Chrome Serial support for Avrgirl Arduino + +## methods and properties needed for direct mappings / translation interface + +### constructor / static ++ `new SerialPort()` -> `navigator.serial.requestPort` ++ `SerialPort.list` -> `navigator.serial.getPorts` + +### instance ++ `serialPort.open` -> `serialPort.open` ++ `serialPort.path` -> manually set after user gesture and user permission granted? I don't see it in the port info object ++ `serialPort.close` -> `serialPort.close` ++ `serialPort.set` -> `serialPort.setControlSignals` ++ `serialPort.write` -> `serialPort.writeable.getWriter().write` ++ `serialPort.read` -> `serialPort.readable.getReader().read` ++ `serialPort.flush` -> `serialPort.flush` + +### events ++ error ++ close ++ open + +**Note:** this list is not exhaustive of node serialport but these are the minimum requirements in order to bootstrap Avrgirl Arduino + +## questions ++ what should the default buffer size be for writing? Although in Avrgirl we can set this to the pageSize + amount of control bytes needed for opcodes ++ should the browser serialport library shim be written in typescript? (probably) ++ how are the pid and vid properties extracted? Assumption is that they're included in the properties of `getPorts` results though I don't see it in the fake mock that Reilly wrote ++ how can a static method be declared in an ES6 class declaration? I forget right now and I don't have internet for a week to look it up ++ should a more modern interface of promises be an option for the library shim while remaining compatible with existing callback implementation? ++ should the bundler be changed from browserify to webpack? graceful-fs would need to be swapped out for regular fs if so ++ do the events all match up to equivalencies? ++ perhaps the serialPort.path needs to be the id of the serial device instance? How do we reconnect after a reset of the device? + diff --git a/package.json b/package.json index 0ce96d4..ebbf316 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "3.0.2", "description": "A NodeJS library for flashing compiled sketch files to Arduino microcontroller boards.", "bin": "./bin/cli.js", - "main": "avrgirl-arduino.js", + "main": "avrgirl-arduino-node.js", "scripts": { "test": "gulp test", "cover": "istanbul cover ./tests/*.spec.js && istanbul-coveralls" From 3023a9dd5baec14443543741b44bf444457df3b7 Mon Sep 17 00:00:00 2001 From: Suz Hinton Date: Sun, 22 Sep 2019 17:02:05 -0700 Subject: [PATCH 05/94] bug fixes and webpack bundling --- dist/avrgirl-arduino.global.js | 22 + dist/avrgirl-arduino.global.min.js | 2 + dist/avrgirl-arduino.global.min.js.LICENSE | 14 + dist/avrgirl-arduino.js | 22 + dist/avrgirl-arduino.min.js | 2 + dist/avrgirl-arduino.min.js.LICENSE | 14 + index.html | 65 + lib/browser-serialport.js | 52 +- lib/connection-browser.js | 34 +- lib/tools.js | 7 +- package-lock.json | 2139 +++++++++++++++++++- package.json | 8 +- tests/demos/arduboy.js | 2 +- tests/demos/blend-micro.js | 2 +- tests/demos/circuit-playground-classic.js | 2 +- tests/demos/due168.js | 2 +- tests/demos/feather.js | 2 +- tests/demos/imuduino.js | 2 +- tests/demos/leonardo.js | 2 +- tests/demos/lilypad-usb.js | 2 +- tests/demos/mega.js | 2 +- tests/demos/micro.js | 2 +- tests/demos/nano.js | 2 +- tests/demos/pinoccio.js | 2 +- tests/demos/pro-mini.js | 2 +- tests/demos/qduino.js | 2 +- tests/demos/sf-pro-micro.js | 2 +- tests/demos/tinyduino.js | 2 +- tests/demos/uno.js | 2 +- webpack.config.js | 50 + 30 files changed, 2370 insertions(+), 95 deletions(-) create mode 100644 dist/avrgirl-arduino.global.js create mode 100644 dist/avrgirl-arduino.global.min.js create mode 100644 dist/avrgirl-arduino.global.min.js.LICENSE create mode 100644 dist/avrgirl-arduino.js create mode 100644 dist/avrgirl-arduino.min.js create mode 100644 dist/avrgirl-arduino.min.js.LICENSE create mode 100644 index.html create mode 100644 webpack.config.js diff --git a/dist/avrgirl-arduino.global.js b/dist/avrgirl-arduino.global.js new file mode 100644 index 0000000..51808ac --- /dev/null +++ b/dist/avrgirl-arduino.global.js @@ -0,0 +1,22 @@ +window.AvrgirlArduino=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=30)}([function(t,e,n){"use strict";(function(t){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +var r=n(32),i=n(33),o=n(20);function u(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(u()=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(r)return F(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return O(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){var o,u=1,a=t.length,s=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,a/=2,s/=2,n/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(i){var f=-1;for(o=n;oa&&(n=a-s),o=n;o>=0;o--){for(var l=!0,p=0;pi&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var u=0;u>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function T(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&c)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=t[i+1],u=t[i+2],a=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&a)&&(s=(15&c)<<18|(63&o)<<12|(63&u)<<6|63&a)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=l}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0),a=Math.min(o,u),c=this.slice(r,i),f=t.slice(e,n),l=0;li)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":return _(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function R(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function I(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function j(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function L(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(t,e,n,r,o){return o||L(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return o||L(t,0,n,8),i.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=this[t],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=0,u=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=n-1,u=1,a=0;for(this[e+o]=255&t;--o>=0&&(u*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/u>>0)-a&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function q(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(2))},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,c=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?c=s.concat(c):l=-1,c.length&&h())}function h(){if(!f){var t=a(p);f=!0;for(var e=c.length;e;){for(s=c,c=[];++l1)for(var n=1;n1)for(var o=1;o0&&u.length>i&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=u.length,a=s,console&&console.warn&&console.warn(a)}return t}function l(){for(var t=[],e=0;e0&&(u=e[0]),u instanceof Error)throw u;var a=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw a.context=u,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)o(s,this,e);else{var c=s.length,f=g(s,c);for(n=0;n=0;o--)if(n[o]===e||n[o].listener===e){u=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},a.prototype.listeners=function(t){return h(this,t,!0)},a.prototype.rawListeners=function(t){return h(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},a.prototype.listenerCount=d,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(36),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(2))},function(t,e,n){(function(t){function n(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===n(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===n(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===n(t)},e.isError=function(t){return"[object Error]"===n(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,n(0).Buffer)},function(t,e,n){(function(t){var r=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,t,r.depth)}function s(t,e){var n=a.styles[e];return n?"["+a.colors[n][0]+"m"+t+"["+a.colors[n][1]+"m":t}function c(t,e){return t}function f(t,n,r){if(t.customInspect&&n&&E(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=f(t,i,r)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(y(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,n);if(o)return o;var u=Object.keys(n),a=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(n)),S(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return l(n);if(0===u.length){if(E(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(b(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(_(n))return t.stylize(Date.prototype.toString.call(n),"date");if(S(n))return l(n)}var c,w="",x=!1,T=["{","}"];(h(n)&&(x=!0,T=["[","]"]),E(n))&&(w=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(w=" "+RegExp.prototype.toString.call(n)),_(n)&&(w=" "+Date.prototype.toUTCString.call(n)),S(n)&&(w=" "+l(n)),0!==u.length||x&&0!=n.length?r<0?b(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),c=x?function(t,e,n,r,i){for(var o=[],u=0,a=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(c,w,T)):T[0]+w+T[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,n,r,i,o){var u,a,s;if((s=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(a=t.stylize("[Setter]","special")),R(r,i)||(u="["+i+"]"),a||(t.seen.indexOf(s.value)<0?(a=g(n)?f(t,s.value,null):f(t,s.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),m(u)){if(o&&i.match(/^\d+$/))return a;(u=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+a}function h(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return void 0===t}function b(t){return w(t)&&"[object RegExp]"===x(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===x(t)}function S(t){return w(t)&&("[object Error]"===x(t)||t instanceof Error)}function E(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(m(o)&&(o=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!u[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=t.pid;u[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else u[n]=function(){};return u[n]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=d,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=y,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=b,e.isObject=w,e.isDate=_,e.isError=S,e.isFunction=E,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(56);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",k(),e.format.apply(e,arguments))},e.inherits=n(3),e._extend=function(t,e){if(!e||!w(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function P(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(O&&t[O]){var e;if("function"!=typeof(e=t[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,O,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),i=[],o=0;o-1&&t%1==0&&t<=U}function z(t){return null!=t&&N(t.length)&&!function(t){if(!s(t))return!1;var e=D(t);return e==j||e==L||e==I||e==B}(t)}var F={};function q(){}function G(t){return function(){if(null!==t){var e=t;t=null,e.apply(this,arguments)}}}var Y="function"==typeof Symbol&&Symbol.iterator,K=function(t){return Y&&t[Y]&&t[Y]()};function W(t){return null!=t&&"object"==typeof t}var H="[object Arguments]";function V(t){return W(t)&&D(t)==H}var $=Object.prototype,Q=$.hasOwnProperty,J=$.propertyIsEnumerable,Z=V(function(){return arguments}())?V:function(t){return W(t)&&Q.call(t,"callee")&&!J.call(t,"callee")},X=Array.isArray,tt="object"==typeof e&&e&&!e.nodeType&&e,et=tt&&"object"==typeof i&&i&&!i.nodeType&&i,nt=et&&et.exports===tt?E.Buffer:void 0,rt=(nt?nt.isBuffer:void 0)||function(){return!1},it=9007199254740991,ot=/^(?:0|[1-9]\d*)$/;function ut(t,e){return!!(e=null==e?it:e)&&("number"==typeof t||ot.test(t))&&t>-1&&t%1==0&&t2&&(r=o(arguments,1)),e){var c={};Ft(i,(function(t,e){c[e]=t})),c[t]=r,a=!0,s=Object.create(null),n(e,c)}else i[t]=r,d(t)}));u++;var c=b(e[e.length-1]);e.length>1?c(i,r):c(r)}}(t,e)}))}function h(){if(0===c.length&&0===u)return n(null,i);for(;c.length&&u=0&&n.push(r)})),n}Ft(t,(function(e,n){if(!X(e))return p(n,[e]),void f.push(n);var r=e.slice(0,e.length-1),i=r.length;if(0===i)return p(n,e),void f.push(n);l[n]=i,Ut(r,(function(o){if(!t[o])throw new Error("async.auto task `"+n+"` has a non-existent dependency `"+o+"` in "+r.join(", "));var u,a,c;a=function(){0==--i&&p(n,e)},(c=s[u=o])||(c=s[u]=[]),c.push(a)}))})),function(){for(var t,e=0;f.length;)t=f.pop(),e++,Ut(g(t),(function(t){0==--l[t]&&f.push(t)}));if(e!==r)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),h()};function Kt(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n=r?t:function(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=Array(i);++r-1;);return n}(i,o),function(t,e){for(var n=t.length;n--&&Gt(e,t[n],0)>-1;);return n}(i,o)+1).join("")}var pe=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,he=/,/,de=/(=.+)?(\s*)$/,ge=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function ye(t,e){var n={};Ft(t,(function(t,e){var r,i=m(t),o=!i&&1===t.length||i&&0===t.length;if(X(t))r=t.slice(0,-1),t=t[t.length-1],n[e]=r.concat(r.length>0?u:t);else if(o)n[e]=t;else{if(r=function(t){return t=(t=(t=(t=t.toString().replace(ge,"")).match(pe)[2].replace(" ",""))?t.split(he):[]).map((function(t){return le(t.replace(de,""))}))}(t),0===t.length&&!i&&0===r.length)throw new Error("autoInject task functions require explicit parameters.");i||r.pop(),n[e]=r.concat(u)}function u(e,n){var i=Kt(r,(function(t){return e[t]}));i.push(n),b(t).apply(null,i)}})),Yt(n,e)}function ve(){this.head=this.tail=null,this.length=0}function me(t,e){t.length=1,t.head=t.tail=e}function be(t,e,n){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var r=b(t),i=0,o=[],u=!1;function a(t,e,n){if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");if(f.started=!0,X(t)||(t=[t]),0===t.length&&f.idle())return h((function(){f.drain()}));for(var r=0,i=t.length;r0&&o.splice(a,1),u.callback.apply(u,arguments),null!=e&&f.error(e,u.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new ve,concurrency:e,payload:n,saturated:q,unsaturated:q,buffer:e/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(t,e){a(t,!1,e)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(t,e){a(t,!0,e)},remove:function(t){f._tasks.remove(t)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(i=o(arguments,1)),r[e]=i,n(t)}))}),(function(t){n(t,r)}))}function vn(t,e){yn(Ot,t,e)}function mn(t,e,n){yn(xt(e),t,n)}var bn=function(t,e){var n=b(t);return be((function(t,e){n(t[0],e)}),e,1)},wn=function(t,e){var n=bn(t,e);return n.push=function(t,e,r){if(null==r&&(r=q),"function"!=typeof r)throw new Error("task callback must be a function");if(n.started=!0,X(t)||(t=[t]),0===t.length)return h((function(){n.drain()}));e=e||0;for(var i=n._tasks.head;i&&e>=i.priority;)i=i.next;for(var o=0,u=t.length;or?1:0}Mt(t,(function(t,e){r(t,(function(n,r){if(n)return e(n);e(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,Kt(e.sort(i),Je("value")))}))}function Bn(t,e,n){var r=b(t);return a((function(i,o){var u,a=!1;i.push((function(){a||(o.apply(null,arguments),clearTimeout(u))})),u=setTimeout((function(){var e=t.name||"anonymous",r=new Error('Callback function "'+e+'" timed out.');r.code="ETIMEDOUT",n&&(r.info=n),a=!0,o(r)}),e),r.apply(null,i)}))}var Un=Math.ceil,Nn=Math.max;function zn(t,e,n,r){var i=b(n);jt(function(t,e,n,r){for(var i=-1,o=Nn(Un((e-t)/(n||1)),0),u=Array(o);o--;)u[r?o:++i]=t,t+=n;return u}(0,t,1),e,i,r)}var Fn=At(zn,1/0),qn=At(zn,1);function Gn(t,e,n,r){arguments.length<=3&&(r=n,n=e,e=X(t)?[]:{}),r=G(r||q);var i=b(n);Ot(t,(function(t,n,r){i(e,t,n,r)}),(function(t){r(t,e)}))}function Yn(t,e){var n,r=null;e=e||q,Ke(t,(function(t,e){b(t)((function(t,i){n=arguments.length>2?o(arguments,1):i,r=t,e(!t)}))}),(function(){e(r,n)}))}function Kn(t){return function(){return(t.unmemoized||t).apply(null,arguments)}}function Wn(t,e,n){n=Et(n||q);var r=b(e);if(!t())return n(null);var i=function(e){if(e)return n(e);if(t())return r(i);var u=o(arguments,1);n.apply(null,[null].concat(u))};r(i)}function Hn(t,e,n){Wn((function(){return!t.apply(this,arguments)}),e,n)}var Vn=function(t,e){if(e=G(e||q),!X(t))return e(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return e();var n=0;function r(e){var r=b(t[n++]);e.push(Et(i)),r.apply(null,e)}function i(i){if(i||n===t.length)return e.apply(null,arguments);r(o(arguments,1))}r([])},$n={apply:u,applyEach:Dt,applyEachSeries:Bt,asyncify:d,auto:Yt,autoInject:ye,cargo:we,compose:xe,concat:ke,concatLimit:Ae,concatSeries:Re,constant:Oe,detect:De,detectLimit:Ie,detectSeries:je,dir:Be,doDuring:Ue,doUntil:ze,doWhilst:Ne,during:Fe,each:Ge,eachLimit:Ye,eachOf:Ot,eachOfLimit:Tt,eachOfSeries:_e,eachSeries:Ke,ensureAsync:We,every:Ve,everyLimit:$e,everySeries:Qe,filter:en,filterLimit:nn,filterSeries:rn,forever:on,groupBy:an,groupByLimit:un,groupBySeries:sn,log:cn,map:Mt,mapLimit:jt,mapSeries:Lt,mapValues:ln,mapValuesLimit:fn,mapValuesSeries:pn,memoize:dn,nextTick:gn,parallel:vn,parallelLimit:mn,priorityQueue:wn,queue:bn,race:_n,reduce:Se,reduceRight:Sn,reflect:En,reflectAll:xn,reject:An,rejectLimit:kn,rejectSeries:Rn,retry:Pn,retryable:Cn,seq:Ee,series:Mn,setImmediate:h,some:Dn,someLimit:In,someSeries:jn,sortBy:Ln,timeout:Bn,times:Fn,timesLimit:zn,timesSeries:qn,transform:Gn,tryEach:Yn,unmemoize:Kn,until:Hn,waterfall:Vn,whilst:Wn,all:Ve,allLimit:$e,allSeries:Qe,any:Dn,anyLimit:In,anySeries:jn,find:De,findLimit:Ie,findSeries:je,forEach:Ge,forEachSeries:Ke,forEachLimit:Ye,forEachOf:Ot,forEachOfSeries:_e,forEachOfLimit:Tt,inject:Se,foldl:Se,foldr:Sn,select:en,selectLimit:nn,selectSeries:rn,wrapSync:d};e.default=$n,e.apply=u,e.applyEach=Dt,e.applyEachSeries=Bt,e.asyncify=d,e.auto=Yt,e.autoInject=ye,e.cargo=we,e.compose=xe,e.concat=ke,e.concatLimit=Ae,e.concatSeries=Re,e.constant=Oe,e.detect=De,e.detectLimit=Ie,e.detectSeries=je,e.dir=Be,e.doDuring=Ue,e.doUntil=ze,e.doWhilst=Ne,e.during=Fe,e.each=Ge,e.eachLimit=Ye,e.eachOf=Ot,e.eachOfLimit=Tt,e.eachOfSeries=_e,e.eachSeries=Ke,e.ensureAsync=We,e.every=Ve,e.everyLimit=$e,e.everySeries=Qe,e.filter=en,e.filterLimit=nn,e.filterSeries=rn,e.forever=on,e.groupBy=an,e.groupByLimit=un,e.groupBySeries=sn,e.log=cn,e.map=Mt,e.mapLimit=jt,e.mapSeries=Lt,e.mapValues=ln,e.mapValuesLimit=fn,e.mapValuesSeries=pn,e.memoize=dn,e.nextTick=gn,e.parallel=vn,e.parallelLimit=mn,e.priorityQueue=wn,e.queue=bn,e.race=_n,e.reduce=Se,e.reduceRight=Sn,e.reflect=En,e.reflectAll=xn,e.reject=An,e.rejectLimit=kn,e.rejectSeries=Rn,e.retry=Pn,e.retryable=Cn,e.seq=Ee,e.series=Mn,e.setImmediate=h,e.some=Dn,e.someLimit=In,e.someSeries=jn,e.sortBy=Ln,e.timeout=Bn,e.times=Fn,e.timesLimit=zn,e.timesSeries=qn,e.transform=Gn,e.tryEach=Yn,e.unmemoize=Kn,e.until=Hn,e.waterfall=Vn,e.whilst=Wn,e.all=Ve,e.allLimit=$e,e.allSeries=Qe,e.any=Dn,e.anyLimit=In,e.anySeries=jn,e.find=De,e.findLimit=Ie,e.findSeries=je,e.forEach=Ge,e.forEachSeries=Ke,e.forEachLimit=Ye,e.forEachOf=Ot,e.forEachOfSeries=_e,e.forEachOfLimit=Tt,e.inject=Se,e.foldl=Se,e.foldr=Sn,e.select=en,e.selectLimit=nn,e.selectSeries=rn,e.wrapSync=d,Object.defineProperty(e,"__esModule",{value:!0})})(e)}).call(this,n(7).setImmediate,n(1),n(2),n(37)(t))},function(t,e,n){(function(e){var r=n(21),i=n(22),o={_parseHex:function(t){try{var n;return n="string"==typeof t?r.readFileSync(t,{encoding:"utf8"}):e.from(t),i.parse(n).data}catch(t){return t}},_hexStringToByte:function(t){return e.from([parseInt(t,16)])}};t.exports=o}).call(this,n(0).Buffer)},function(t,e,n){var r=n(0).Buffer;t.exports=function(t,e){if(r.isBuffer(t)&&r.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var n=0;n-1?r:o.nextTick;m.WritableState=v;var c=n(8);c.inherits=n(3);var f={deprecate:n(67)},l=n(26),p=n(11).Buffer,h=i.Uint8Array||function(){};var d,g=n(27);function y(){}function v(t,e){a=a||n(4),t=t||{};var r=e instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?(o.nextTick(i,r),o.nextTick(x,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(i(r),t._writableState.errorEmitted=!0,t.emit("error",r),x(t,e))}(t,n,r,e,i);else{var u=S(n);u||n.corked||n.bufferProcessing||!n.bufferedRequest||_(t,n),r?s(w,t,n,u,i):w(t,n,u,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new u(this)}function m(t){if(a=a||n(4),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new v(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function b(t,e,n,r,i,o,u){e.writelen=r,e.writecb=u,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function w(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),x(t,e)}function _(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)i[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;i.allBuffers=s,b(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new u(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(b(t,e,!1,e.objectMode?1:c.length,c,f,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final((function(n){e.pendingcb--,n&&t.emit("error",n),e.prefinished=!0,t.emit("prefinish"),x(t,e)}))}function x(t,e){var n=S(e);return n&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}c.inherits(m,l),v.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(v.prototype,"buffer",{get:f.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof v)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,n){var r,i=this._writableState,u=!1,a=!i.objectMode&&(r=t,p.isBuffer(r)||r instanceof h);return a&&!p.isBuffer(t)&&(t=function(t){return p.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=y),i.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),o.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var i=!0,u=!1;return null===n?u=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||e.objectMode||(u=new TypeError("Invalid non-string/buffer chunk")),u&&(t.emit("error",u),o.nextTick(r,u),i=!1),i}(this,i,t,n))&&(i.pendingcb++,u=function(t,e,n,r,i,o){if(!n){var u=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=p.from(e,n));return e}(e,r,i);r!==u&&(n=!0,i="buffer",r=u)}var a=e.objectMode?1:r.length;e.length+=a;var s=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,x(t,e),n&&(e.finished?o.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=g.destroy,m.prototype._undestroy=g.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,n(1),n(7).setImmediate,n(2))},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){},function(t,e,n){(function(t){e.parse=function(e,n){e instanceof t&&(e=e.toString("ascii"));var r=new t(n||8192),i=0,o=0,u=null,a=null,s=0,c=0;for(;c+11<=e.length;){if(":"!=e.charAt(c++))throw new Error("Line "+(s+1)+" does not start with a colon (:).");s++;var f=parseInt(e.substr(c,2),16);c+=2;var l=parseInt(e.substr(c,4),16);c+=4;var p=parseInt(e.substr(c,2),16);c+=2;var h=e.substr(c,2*f),d=new t(h,"hex");c+=2*f;var g=parseInt(e.substr(c,2),16);c+=2;for(var y=f+(l>>8)+l+p&255,v=0;v=r.length){var b=new t(2*(m+f));r.copy(b,0,0,i),r=b}m>i&&r.fill(255,i,m),d.copy(r,m),i=Math.max(i,m+f);break;case 1:if(0!=f)throw new Error("Invalid EOF record on line "+s+".");return{data:r.slice(0,i),startSegmentAddress:u,startLinearAddress:a};case 2:if(2!=f||0!=l)throw new Error("Invalid extended segment address record on line "+s+".");o=parseInt(h,16)<<4;break;case 3:if(4!=f||0!=l)throw new Error("Invalid start segment address record on line "+s+".");u=parseInt(h,16);break;case 4:if(2!=f||0!=l)throw new Error("Invalid extended linear address record on line "+s+".");o=parseInt(h,16)<<16;break;case 5:if(4!=f||0!=l)throw new Error("Invalid start linear address record on line "+s+".");a=parseInt(h,16);break;default:throw new Error("Invalid record type ("+p+") on line "+s)}"\r"==e.charAt(c)&&c++,"\n"==e.charAt(c)&&c++}throw new Error("Unexpected end of input: missing or invalid EOF record.")}}).call(this,n(0).Buffer)},function(t,e){function n(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}n.keys=function(){return[]},n.resolve=n,t.exports=n,n.id=23},function(t,e){t.exports.MESSAGE_START=27,t.exports.TOKEN=14,t.exports.CMD_SIGN_ON=1,t.exports.CMD_SET_PARAMETER=2,t.exports.CMD_GET_PARAMETER=3,t.exports.CMD_SET_DEVICE_PARAMETERS=4,t.exports.CMD_OSCCAL=5,t.exports.CMD_LOAD_ADDRESS=6,t.exports.CMD_FIRMWARE_UPGRADE=7,t.exports.CMD_ENTER_PROGMODE_ISP=16,t.exports.CMD_LEAVE_PROGMODE_ISP=17,t.exports.CMD_CHIP_ERASE_ISP=18,t.exports.CMD_PROGRAM_FLASH_ISP=19,t.exports.CMD_READ_FLASH_ISP=20,t.exports.CMD_PROGRAM_EEPROM_ISP=21,t.exports.CMD_READ_EEPROM_ISP=22,t.exports.CMD_PROGRAM_FUSE_ISP=23,t.exports.CMD_READ_FUSE_ISP=24,t.exports.CMD_PROGRAM_LOCK_ISP=25,t.exports.CMD_READ_LOCK_ISP=26,t.exports.CMD_READ_SIGNATURE_ISP=27,t.exports.CMD_READ_OSCCAL_ISP=28,t.exports.CMD_SPI_MULTI=29,t.exports.CMD_ENTER_PROGMODE_PP=32,t.exports.CMD_LEAVE_PROGMODE_PP=33,t.exports.CMD_CHIP_ERASE_PP=34,t.exports.CMD_PROGRAM_FLASH_PP=35,t.exports.CMD_READ_FLASH_PP=36,t.exports.CMD_PROGRAM_EEPROM_PP=37,t.exports.CMD_READ_EEPROM_PP=38,t.exports.CMD_PROGRAM_FUSE_PP=39,t.exports.CMD_READ_FUSE_PP=40,t.exports.CMD_PROGRAM_LOCK_PP=41,t.exports.CMD_READ_LOCK_PP=42,t.exports.CMD_READ_SIGNATURE_PP=43,t.exports.CMD_READ_OSCCAL_PP=44,t.exports.CMD_SET_CONTROL_STACK=45,t.exports.CMD_ENTER_PROGMODE_HVSP=48,t.exports.CMD_LEAVE_PROGMODE_HVSP=49,t.exports.CMD_CHIP_ERASE_HVSP=50,t.exports.CMD_PROGRAM_FLASH_HVSP=51,t.exports.CMD_READ_FLASH_HVSP=52,t.exports.CMD_PROGRAM_EEPROM_HVSP=53,t.exports.CMD_READ_EEPROM_HVSP=54,t.exports.CMD_PROGRAM_FUSE_HVSP=55,t.exports.CMD_READ_FUSE_HVSP=56,t.exports.CMD_PROGRAM_LOCK_HVSP=57,t.exports.CMD_READ_LOCK_HVSP=58,t.exports.CMD_READ_SIGNATURE_HVSP=59,t.exports.CMD_READ_OSCCAL_HVSP=60,t.exports.STATUS_CMD_OK=0,t.exports.STATUS_CMD_TOUT=128,t.exports.STATUS_RDY_BSY_TOUT=129,t.exports.STATUS_SET_PARAM_MISSING=130,t.exports.STATUS_CMD_FAILED=192,t.exports.STATUS_CKSUM_ERROR=193,t.exports.STATUS_CMD_UNKNOWN=201,t.exports.STATUS_BUILD_NUMBER_LOW=128,t.exports.STATUS_BUILD_NUMBER_HIGH=129,t.exports.STATUS_HW_VER=144,t.exports.STATUS_SW_MAJOR=145,t.exports.STATUS_SW_MINOR=146,t.exports.STATUS_VTARGET=148,t.exports.STATUS_VADJUST=149,t.exports.STATUS_OSC_PSCALE=150,t.exports.STATUS_OSC_CMATCH=151,t.exports.STATUS_SCK_DURATION=152,t.exports.STATUS_TOPCARD_DETECT=154,t.exports.STATUS_STATUS=156,t.exports.STATUS_DATA=157,t.exports.STATUS_RESET_POLARITY=158,t.exports.STATUS_CONTROLLER_INIT=159,t.exports.ANSWER_CKSUM_ERROR=176},function(t,e,n){"use strict";(function(e,r){var i=n(10);t.exports=b;var o,u=n(20);b.ReadableState=m;n(6).EventEmitter;var a=function(t,e){return t.listeners(e).length},s=n(26),c=n(11).Buffer,f=e.Uint8Array||function(){};var l=n(8);l.inherits=n(3);var p=n(64),h=void 0;h=p&&p.debuglog?p.debuglog("stream"):function(){};var d,g=n(65),y=n(27);l.inherits(b,s);var v=["error","close","destroy","pause","resume"];function m(t,e){t=t||{};var r=e instanceof(o=o||n(4));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,u=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(u||0===u)?u:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(28).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function b(t){if(o=o||n(4),!(this instanceof b))return new b(t);this._readableState=new m(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function w(t,e,n,r,i){var o,u=t._readableState;null===e?(u.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,x(t)}(t,u)):(i||(o=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(u,e)),o?t.emit("error",o):u.objectMode||e&&e.length>0?("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?u.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,u,e,!0):u.ended?t.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!n?(e=u.decoder.write(e),u.objectMode||0!==e.length?_(t,u,e,!1):A(t,u)):_(t,u,e,!1))):r||(u.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=S?t=S:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(h("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(T,t):T(t))}function T(t){h("emit readable"),t.emit("readable"),P(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;to.length?o.length:t;if(u===o.length?i+=o:i+=o.slice(0,t),0===(t-=u)){u===o.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(u));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var o=r.data,u=t>o.length?o.length:t;if(o.copy(n,n.length-t,0,u),0===(t-=u)){u===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(u));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function I(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return h("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):x(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return h("need readable",i),(0===e.length||e.length-t0?C(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:b;function c(e,r){h("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,h("cleanup"),t.removeListener("close",v),t.removeListener("finish",m),t.removeListener("drain",l),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",b),n.removeListener("data",g),p=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){h("onend"),t.end()}o.endEmitted?i.nextTick(s):n.once("end",s),t.on("unpipe",c);var l=function(t){return function(){var e=t._readableState;h("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",l);var p=!1;var d=!1;function g(e){h("ondata"),d=!1,!1!==t.write(e)||d||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==I(o.pipes,t))&&!p&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){h("onerror",e),b(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",m),b()}function m(){h("onfinish"),t.removeListener("close",v),b()}function b(){h("unpipe"),n.unpipe(t)}return n.on("data",g),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?u(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",v),t.once("finish",m),t.emit("pipe",n),o.flowing||(h("pipe resume"),n.resume()),t},b.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function s(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function f(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function p(t){return t.toString(this.encoding)}function h(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(t.lastNeed=i-1),i;if(--r=0)return i>0&&(t.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,n){"use strict";t.exports=u;var r=n(4),i=n(8);function o(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length0?u-4:u;for(n=0;n>16&255,s[f++]=e>>8&255,s[f++]=255&e;2===a&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,s[f++]=255&e);1===a&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,s[f++]=e>>8&255,s[f++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],u=0,a=n-i;ua?a:u+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=u.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t,e,n){for(var i,o,u=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return u.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,i){var o,u,a=8*i-r-1,s=(1<>1,f=-7,l=n?i-1:0,p=n?-1:1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=p,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=r;f>0;u=256*u+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===s)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),o-=c}return(h?-1:1)*u*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var u,a,s,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=f):(u=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-u))<1&&(u--,s*=2),(e+=u+l>=1?p/s:p*Math.pow(2,1-l))*s>=2&&(u++,s/=2),u+l>=f?(a=0,u=f):u+l>=1?(a=(e*s-1)*Math.pow(2,i),u+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),u=0));i>=8;t[n+h]=255&a,h+=d,a/=256,i-=8);for(u=u<0;t[n+h]=255&u,h+=d,u/=256,c-=8);t[n+h-d]|=128*g}},function(t,e,n){var r=n(35),i=n(12),o=n(38),u=(n(13),function(t){this.options=t,this.debug=this.options.debug?console.log.bind(console):function(){},this.board=this.options.board});u.prototype._init=function(t){this._setUpSerial((function(e){return t(e)}))},u.prototype._setUpSerial=function(t){return this.serialPort=new r("",{baudRate:this.board.baud,autoOpen:!1}),t(null)},u.prototype._sniffPort=function(t){var e=this.board.productId.map((function(t){return parseInt(t,16)}));this._listPorts((function(n,r){var i=r.filter((function(t){return-1!==e.indexOf(parseInt(t._standardPid,16))}));return t(null,i)}))},u.prototype._setDTR=function(t,e,n){var r={rts:t,dtr:t};this.serialPort.set(r,(function(t){if(t)return n(t);setTimeout((function(){n(t)}),e)}))},u.prototype._pollForPort=function(t){var e=this,n=o((function(t){var n=!1;e._sniffPort((function(r,i){i.length&&(e.options.port=i[0].comName,n=!0),t(n)}))}));n.every(100).ask(15),n((function(n){if(!n)return t(new Error("could not reconnect after resetting board."));e.debug("found port on",e.options.port),e._setUpSerial((function(e){return t(e)}))}))},u.prototype._pollForOpen=function(t){var e=this,n=o((function(t){e.serialPort.open((function(e){t(!e)}))}));n.every(200).ask(10),n((function(n){var r;n||(r=new Error("could not open board on "+e.serialPort.path)),t(r)}))},u.prototype._cycleDTR=function(t){i.series([this._setDTR.bind(this,!0,250),this._setDTR.bind(this,!1,50)],(function(e){return t(e)}))},u.prototype._listPorts=function(t){var e=[];r.list((function(n,r){if(n)return t(n);for(var i=0;it(null,e)).catch(e=>t(e))}open(t){navigator.serial.requestPort(this.requestOptions).then(t=>(this.port=t,this.port.open({baudrate:this.baudrate||57600}))).then(()=>this.writer=this.port.writable.getWriter()).then(()=>this.reader=this.port.readable.getReader()).then(async()=>{for(this.emit("open"),t(null);this.port.readable;)try{for(;;){const{value:t,done:n}=await this.reader.read();if(n)break;this.emit("data",e.from(t))}}catch(t){console.log("ERROR while reading port:",t)}}).catch(e=>{t(e)})}close(t){if(this.port.close(),t)return t(null)}set(t,e){this.port.setSignals(t).then(()=>e(null)).catch(t=>e(t))}write(t,e){return this.writer.write(t),e(null)}read(t){this.reader.read().then(e=>t(null,e)).catch(e=>t(e))}flush(){this.port.flush()}}}).call(this,n(0).Buffer)},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,u,a,s=1,c={},f=!1,l=t.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(t);p=p&&p.setTimeout?p:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){o.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(t){var e=l.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(u="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(u)&&d(+e.data.slice(u.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),r=function(e){t.postMessage(u+e,"*")}),p.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=o?n&&(n=null,r(!!t)):(u&&(!0===u?e=i(e,c):e+=c*u),s=setTimeout(f,e))}return(e=function(t){if(s&&(clearTimeout(s),s=null,n&&n(!1),n=null,c=0),arguments.length){if(!r(t,"function"))throw new TypeError("done callback must be a function");n=t}s=setTimeout(f,a)}).ask=function(t){if(s)throw new SyntaxError("can not set ask limit during polling");if(!r(t,"number"))throw new TypeError("ask limit must be a number");return o=t,e},e.every=function(t){if(s)throw new SyntaxError("can not set timeout during polling");if(!r(t,"number"))throw new TypeError("timout must be a number");return a=t,e},e.incr=function(t){if(s)throw new SyntexError("can not set increment during polling");if(!arguments.length||r(t,"boolean"))u=!!t;else{if(!r(t,"number"))throw new TypeError("increment must be a boolean or number");u=t}return e},e}()}},function(t,e){t.exports=function(t,e){function n(e){return"object"==typeof t&&null!==t}function r(t){return t.name.toLowerCase()}switch(2===arguments.length&&void 0===e?e="undefined":Number.isNaN(e)&&(e="NaN"),e){case"boolean":case"function":case"string":return typeof t===e;case"number":return typeof t===e&&!isNaN(t);case Number:if(isNaN(t))return!1;case String:case Boolean:return typeof t===r(e);case Object:case"object":return n();case"array":return Array.isArray(t);case"regex":case"regexp":return t instanceof RegExp;case"date":return t instanceof Date;case"null":case null:return null===t;case"undefined":return void 0===t;case"NaN":return Number.isNaN(t);case"arguments":return!!n()&&("function"==typeof t.callee||/arguments/i.test(t.toString()));default:return"function"==typeof e?t instanceof e:t}}},function(t,e){t.exports=function(t,e){for(var n=0;n++>8&255,c={cmd:[i.Cmnd_STK_LOAD_ADDRESS,a,s],responseData:i.OK_RESPONSE,timeout:n};o(t,c,(function(t,e){u.log("loaded address",t,e),r(t,e)}))},u.prototype.loadPage=function(t,n,r,u){this.log("load page");var a=this,s=255&n.length,c=n.length>>8,f={cmd:e.concat([new e([i.Cmnd_STK_PROG_PAGE,c,s,70]),n,new e([i.Sync_CRC_EOP])]),responseData:i.OK_RESPONSE,timeout:r};o(t,f,(function(t,e){a.log("loaded page",t,e),u(t,e)}))},u.prototype.upload=function(t,e,n,i,o){this.log("program");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.loadPage(t,u,i,e)},function(t){c.log("programmed page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("page done"),o(t)}))}),(function(t){c.log("upload done"),o(t)}))},u.prototype.exitProgrammingMode=function(t,e,n){this.log("send leave programming mode");var r=this,u={cmd:[i.Cmnd_STK_LEAVE_PROGMODE],responseData:i.OK_RESPONSE,timeout:e};o(t,u,(function(t,e){r.log("sent leave programming mode",t,e),n(t,e)}))},u.prototype.verify=function(t,e,n,i,o){this.log("verify");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.verifyPage(t,u,n,i,e)},function(t){c.log("verified page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("verify done"),o(t)}))}),(function(t){c.log("verify done"),o(t)}))},u.prototype.verifyPage=function(t,n,r,u,a){this.log("verify page");var s=this;match=e.concat([new e([i.Resp_STK_INSYNC]),n,new e([i.Resp_STK_OK])]);var c=n.length>=r?r:n.length,f={cmd:[i.Cmnd_STK_READ_PAGE,c>>8&255,255&c,70],responseLength:match.length,timeout:u};o(t,f,(function(t,e){s.log("confirm page",t,e,e.toString("hex")),a(t,e)}))},u.prototype.bootload=function(t,e,n,i){var o={pagesizehigh:n.pagesizehigh<<8&255,pagesizelow:255&n.pagesizelow};r.series([this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.verifySignature.bind(this,t,n.signature,n.timeout),this.setOptions.bind(this,t,o,n.timeout),this.enterProgrammingMode.bind(this,t,n.timeout),this.upload.bind(this,t,e,n.pageSize,n.timeout),this.verify.bind(this,t,e,n.pageSize,n.timeout),this.exitProgrammingMode.bind(this,t,n.timeout)],(function(t){return i(t)}))},t.exports=u}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i; +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e){var r=n(14),i=n(46),o=n(15);t.exports=function(t,n,u){var a,s=n.timeout||0,c=(o.Resp_STK_INSYNC,o.Resp_STK_NOSYNC,null),f=0;n.responseData&&n.responseData.length>0&&(c=n.responseData),c&&(f=c.length),n.responseLength&&(f=n.responseLength);var l=n.cmd;l instanceof Array&&(l=new e(l.concat(o.Sync_CRC_EOP))),t.write(l,(function(e){if(e)return a=new Error("Sending "+l.toString("hex")+": "+e.message),u(a);i(t,s,f,(function(t,e){return t?(a=new Error("Sending "+l.toString("hex")+": "+t.message),u(a)):c&&!r(e,c)?(a=new Error(l+" response mismatch: "+e.toString("hex")+", "+c.toString("hex")),u(a)):void u(null,e)}))}))}}).call(this,n(0).Buffer)},function(t,e,n){(function(e){var r=[n(15).Resp_STK_INSYNC];t.exports=function(t,n,i,o){var u=new e(0),a=!1,s=null,c=function(t){for(var n=0;!a&&ni)return f(new Error("buffer overflow "+u.length+" > "+i));u.length==i&&f()},f=function(e){s&&clearTimeout(s),t.removeListener("data",c),o(e,u)};n&&n>0&&(s=setTimeout((function(){s=null,f(new Error("receiveData timeout after "+n+"ms"))}),n)),t.on("data",c)}}).call(this,n(0).Buffer)},function(t,e){var n={};t.exports=n;var r={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(r).forEach((function(t){var e=r[t],i=n[t]=[];i.open="["+e[0]+"m",i.close="["+e[1]+"m"}))},function(t,e,n){(function(e){var n=e.argv;t.exports=!(-1!==n.indexOf("--no-color")||-1!==n.indexOf("--color=false")||-1===n.indexOf("--color")&&-1===n.indexOf("--color=true")&&-1===n.indexOf("--color=always")&&(e.stdout&&!e.stdout.isTTY||"win32"!==e.platform&&!("COLORTERM"in e.env||"dumb"!==e.env.TERM&&/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(e.env.TERM))))}).call(this,n(1))},function(t,e){t.exports=function(t,e){var n="";t=(t=t||"Run the trap, drop the bass").split("");var r={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","۝","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return t.forEach((function(t){t=t.toLowerCase();var e=r[t]||[" "],i=Math.floor(Math.random()*e.length);n+=void 0!==r[t]?r[t][i]:t})),n}},function(t,e){t.exports=function(t,e){t=t||" he is here ";var n={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},r=[].concat(n.up,n.down,n.mid);function i(t){return Math.floor(Math.random()*t)}function o(t){var e=!1;return r.filter((function(n){e=n===t})),e}return function(t,e){var r,u,a="";for(u in(e=e||{}).up=void 0===e.up||e.up,e.mid=void 0===e.mid||e.mid,e.down=void 0===e.down||e.down,e.size=void 0!==e.size?e.size:"maxi",t=t.split(""))if(!o(u)){switch(a+=t[u],r={up:0,down:0,mid:0},e.size){case"mini":r.up=i(8),r.mid=i(2),r.down=i(8);break;case"maxi":r.up=i(16)+3,r.mid=i(4)+1,r.down=i(64)+3;break;default:r.up=i(8)+1,r.mid=i(6)/2,r.down=i(8)+1}var s=["up","mid","down"];for(var c in s)for(var f=s[c],l=0;l<=r[f];l++)e[f]&&(a+=n[f][i(n[f].length)])}return a}(t,e)}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){if(" "===t)return t;switch(e%3){case 0:return r.red(t);case 1:return r.white(t);case 2:return r.blue(t)}}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){return e%2==0?t:r.inverse(t)}},function(t,e,n){var r,i=n(5);t.exports=(r=["red","yellow","green","blue","magenta"],function(t,e,n){return" "===t?t:i[r[e++%r.length]](t)})},function(t,e,n){var r,i=n(5);t.exports=(r=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"],function(t,e,n){return" "===t?t:i[r[Math.round(Math.random()*(r.length-1))]](t)})},function(t,e,n){var r=n(5);t.exports=function(){var t=function(t,e){String.prototype.__defineGetter__(t,e)};function e(e){var n=["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","charAt","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","charCodeAt","indexOf","lastIndexof","length","localeCompare","match","replace","search","slice","split","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","trimLeft","trimRight"];Object.keys(e).forEach((function(i){-1!==n.indexOf(i)?console.log("warn: ".red+("String.prototype"+i).magenta+" is probably something you don't want to override. Ignoring style name"):"string"==typeof e[i]?(r[i]=r[e[i]],t(i,(function(){return r[e[i]](this)}))):t(i,(function(){for(var t=this,n=0;n=6){var r=n.message[5];i.writeUInt8(r,0)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,1,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,1)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,2,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,2)}t(e)}))}],(function(e){t(e,i)}))},d.prototype.enterProgrammingMode=function(t,n){var r=this,i=Array.prototype.slice.call(arguments);"function"!=typeof(n=i.pop())&&(n=null),(t="function"!=typeof t&&t||{}).timeout=t.timeout||a,t.stabDelay=t.stabDelay||s,t.cmdexeDelay=t.cmdexeDelay||c,t.synchLoops=t.synchLoops||f,t.byteDelay=t.byteDelay||l,t.pollValue=t.pollValue||p,t.pollIndex=t.pollIndex||h;var o=172,u=83,d=0,g=0,y=new e([16,t.timeout,t.stabDelay,t.cmdexeDelay,t.synchLoops,t.byteDelay,t.pollValue,t.pollIndex,o,u,d,g]);r.parser.send(y,(function(t,e){n(t)}))},d.prototype.loadAddress=function(t,n){msb=t>>24&255|128,xsb=t>>16&255,ysb=t>>8&255,lsb=255&t;var r=new e([6,msb,xsb,ysb,lsb]);this.parser.send(r,(function(t,e){n(t)}))},d.prototype.loadPage=function(t,n){var r=t.length>>8,i=255&t.length,o=new e([19,r,i,193,10,64,76,32,0,0]);o=e.concat([o,t]),this.parser.send(o,(function(t,e){n(t)}))},d.prototype.upload=function(t,e,n){var i,o,u=0,a=this;r.whilst((function(){return u>1,t()},function(t){a.loadAddress(o,t)},function(n){i=t.slice(u,t.length>e?u+e:t.length-1),n()},function(t){a.loadPage(i,t)},function(t){u+=i.length,setTimeout(t,4)}],(function(t){n(t)}))}),(function(t){n(t)}))},d.prototype.exitProgrammingMode=function(t){var n=new e([17,1,1]);this.parser.send(n,(function(e,n){t(e)}))},d.prototype.verify=function(t,e){e()},d.prototype.bootload=function(t,e,n){n()},t.exports=d}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i; +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e,r){var i=n(24),o=n(6).EventEmitter;t.exports=function(t){var n,u,a=(n=new o,u={constants:i,port:t,boundOpen:!1,closed:!1,_inc:-1,_queue:[],_current:!1,states:["Start","GetSequenceNumber","GetMessageSize1","GetMessageSize2","GetToken","GetData","GetChecksum","Done"],state:0,pkt:!1,send:function(t,n){if(this.closed)return e((function(){var t=new Error("this parser is closed.");t.code="E_CLOSED",n(t)}));r.isBuffer(t)||(t=new r(t));var o=this._commandTimeout(t[0]),u=new r([0,0]);u.writeUInt16BE(t.length,0);var a=r.concat([new r([i.MESSAGE_START,this._seq(),u[0],u[1],i.TOKEN]),t]),s=this.checksum(a);this._queue.push({buf:r.concat([a,new r([s])]),seq:this._inc,cb:n,timeout:o}),this._send()},checksum:function(t){for(var e=0,n=0;n255&&(this._inc=0),this._inc},_commandTimeout:function(t){if(timeout=1e3,t===i.CMD_SIGN_ON)timeout=200;else for(var e=Object.keys(i),n=0;n-1||e[n].indexOf("PROGRAM_FLASH")>-1||e[n].indexOf("EEPROM")>-1)&&(timeout=5e3);break}return timeout},_send:function(){if(this.closed)return!1;if(!this._current&&this._queue.length)if("function"==typeof t.isOpen?t.isOpen():t.isOpen){var e=this._queue.shift(),n=this._current={timeout:!1,seq:e.seq,cb:e.cb};this._current,this.state=0,r=this,this.port.write(e.buf),this.port.drain((function(){if(n!==r._current)return r.emit("log","current was no longer the current message after drain callback");n.timeout=setTimeout((function(){var t=new Error("stk500 timeout. "+e.timeout+"ms");t.code="E_TIMEOUT",r._resolveCurrent(t)}),e.timeout)})),this.emit("rawinput",e.buf)}else{var r=this;this.boundOpen||t.once("open",(function(){r._send()}))}},_handle:function(t){var e=this._current;if(this.emit("raw",t),!e)return this.emit("log","notice","dropping data","data");for(var n=0;n ");for(var n=0;n126)&&(r="."),e.stdout.write(r+" ["+t.readUInt8(n).toString(16)+"] ")}e.stdout.write("\n")})),this.c=function(t,e,n){return r.cmds.push({value:t,callback:function(t){e&&e(t)},expectedResponseLength:n}),this},this.flashChunkSize=0,this.bytes=[],this.cmds=[]},o.Flasher.prototype={run:function(t){var n=this;e.nextTick((function(){if(!n.running){var i=n.cmds.shift();if(i){running=!0,n.options.debug&&e.stdout.write("Send: "+i.value);var o=new r(0),u=function(a){o=r.concat([o,a]),(void 0===i.expectedResponseLength||i.expectedResponseLength<=o.length)&&(n.sp.removeListener("data",u),n.running=!1,i.callback(o),e.nextTick((function(){n.cmds.length>0?n.run(t):t&&t()})))};n.sp.on("data",u),n.sp.write(i.value)}}}))},prepare:function(t){var e=this;this.c("S",(function(n){n.toString()!==e.signature&&t(new Error("Invalid device signature; expecting: "+e.signature+" received: "+n.toString()))})).c("V").c("v").c("p").c("a").c("b",(function(n){"Y"!=(n.toString()||"X")[0]&&t(new Error("Buffered memory access not supported.")),e.flashChunkSize=n.readUInt16BE(1)})).c("t").c("TD").c("P").c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c([u("A"),3,252]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]),this.run((function(){t(null,e)}))},erase:function(t){this.c("e",(function(){t&&t()})),this.run()},program:function(t,e){var n,r=this,o=[];this.totalBytes=0,this.c([u("A"),0,0],(function(){n=i.parse(t),r.totalBytes=n.data.length,Array.prototype.push.apply(o,n.data),r.allBytes=o,r.options.debug&&console.log("programming",o.length,"bytes"),r.chunksSent=[];for(var e=0;e>8&255,255&a.length,u("F")].concat(a))}})),this.run((function(){e&&e()}))},verify:function(t){var n=this;this.c([u("A"),0,0],(function(){var r=0,i=function(o){var a=null;if(r++,n.allBytes.length){var s=o.length;if(n.allBytes.splice(0,s).forEach((function(t,e){t!==o.readUInt8(e)&&(a=new Error("Firmware on the device does not match local data"))})),a)return t(a);e.nextTick((function(){var t=n.flashChunkSize;n.options.debug&&console.log(n.totalBytes-r*n.flashChunkSize),n.totalBytes-r*n.flashChunkSize>8&255,255&t,u("F")],i,t),n.run()}))}else t&&t()};n.options.debug&&console.log("\n\nVerifying flash.."),n.c([u("g"),n.flashChunkSize>>8&255,255&n.flashChunkSize,u("F")],i,n.flashChunkSize),n.run()})),n.run()},fuseCheck:fuseCheck=function(t){this.options.debug&&console.log("checking fuses"),this.c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c("L").c("E"),this.run((function(){t()}))}},o.init=function(t,e,n){"function"!=typeof e||n||(n=e,e={}),new o.Flasher(t,e).prepare(n)}}).call(this,n(1),n(0).Buffer)},function(t,e,n){t.exports=i;var r=n(6).EventEmitter;function i(){r.call(this)}n(3)(i,r),i.Readable=n(18),i.Writable=n(69),i.Duplex=n(70),i.Transform=n(71),i.PassThrough=n(72),i.Stream=i,i.prototype.pipe=function(t,e){var n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(n.on("end",a),n.on("close",s));var u=!1;function a(){u||(u=!0,t.end())}function s(){u||(u=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===r.listenerCount(this,"error"))throw t}function f(){n.removeListener("data",i),t.removeListener("drain",o),n.removeListener("end",a),n.removeListener("close",s),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",f),n.removeListener("close",f),t.removeListener("close",f)}return n.on("error",c),t.on("error",c),n.on("end",f),n.on("close",f),t.on("close",f),t.emit("pipe",n),t}},function(t,e){},function(t,e,n){"use strict";var r=n(11).Buffer,i=n(66);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var e,n,i,o=r.allocUnsafe(t>>>0),u=this.head,a=0;u;)e=u.data,n=o,i=a,e.copy(n,i),a+=u.data.length,u=u.next;return o},t}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(2))},function(t,e,n){"use strict";t.exports=o;var r=n(29),i=n(8);function o(t){if(!(this instanceof o))return new o(t);r.call(this,t)}i.inherits=n(3),i.inherits(o,r),o.prototype._transform=function(t,e,n){n(null,t)}},function(t,e,n){t.exports=n(19)},function(t,e,n){t.exports=n(4)},function(t,e,n){t.exports=n(18).Transform},function(t,e,n){t.exports=n(18).PassThrough},function(t,e){},function(t,e){t.exports=function(t,e,n){var r=function(r){if(r=r||{},this.options={debug:r.debug||!1,board:r.board||"uno",port:r.port||"",manualReset:r.manualReset||!1},!0===this.options.debug?this.debug=console.log.bind(console):"function"==typeof this.options.debug?this.debug=this.options.debug:this.debug=function(){},"string"==typeof this.options.board?this.options.board=t[this.options.board]:"object"==typeof this.options.board&&(this.options.board=this.options.board),this.options.board&&!this.options.board.manualReset&&(this.options.board.manualReset=this.options.manualReset),this.connection=new e(this.options),this.options.board){var i=n[this.options.board.protocol]||function(){};this.protocol=new i({board:this.options.board,connection:this.connection,debug:this.debug})}};return r.prototype._validateBoard=function(t){if("object"!=typeof this.options.board)return t(new Error('"'+this.options.board+'" is not a supported board type.'));if(this.protocol.chip)return this.options.port||"pro-mini"!==this.options.board.name?t(null):t(new Error("using a pro-mini, please specify the port in your options."));var e="not a supported programming protocol: "+this.options.board.protocol;return t(new Error(e))},r.prototype.flash=function(t,e){var n=this;n._validateBoard((function(r){if(r)return e(r);n.connection._init((function(r){if(r)return e(r);n.protocol._upload(t,e)}))}))},r.prototype.listPorts=r.listPorts=r.prototype.list=r.list=function(t){return e.prototype._listPorts(t)},r.listKnownBoards=function(){return Object.keys(t).filter((function(e){var n=t[e].aliases;return!n||!~n.indexOf(e)}))},r}}]); \ No newline at end of file diff --git a/dist/avrgirl-arduino.global.min.js b/dist/avrgirl-arduino.global.min.js new file mode 100644 index 0000000..198b980 --- /dev/null +++ b/dist/avrgirl-arduino.global.min.js @@ -0,0 +1,2 @@ +/*! For license information please see avrgirl-arduino.global.min.js.LICENSE */ +window.AvrgirlArduino=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=30)}([function(t,e,n){"use strict";(function(t){var r=n(32),i=n(33),o=n(20);function u(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(u()=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(r)return F(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return O(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){var o,u=1,a=t.length,s=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,a/=2,s/=2,n/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(i){var f=-1;for(o=n;oa&&(n=a-s),o=n;o>=0;o--){for(var l=!0,p=0;pi&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var u=0;u>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function T(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&c)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=t[i+1],u=t[i+2],a=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&a)&&(s=(15&c)<<18|(63&o)<<12|(63&u)<<6|63&a)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=l}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0),a=Math.min(o,u),c=this.slice(r,i),f=t.slice(e,n),l=0;li)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":return _(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function R(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function I(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function j(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function L(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(t,e,n,r,o){return o||L(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return o||L(t,0,n,8),i.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=this[t],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=0,u=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=n-1,u=1,a=0;for(this[e+o]=255&t;--o>=0&&(u*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/u>>0)-a&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function q(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(2))},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,c=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?c=s.concat(c):l=-1,c.length&&h())}function h(){if(!f){var t=a(p);f=!0;for(var e=c.length;e;){for(s=c,c=[];++l1)for(var n=1;n1)for(var o=1;o0&&u.length>i&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=u.length,a=s,console&&console.warn&&console.warn(a)}return t}function l(){for(var t=[],e=0;e0&&(u=e[0]),u instanceof Error)throw u;var a=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw a.context=u,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)o(s,this,e);else{var c=s.length,f=g(s,c);for(n=0;n=0;o--)if(n[o]===e||n[o].listener===e){u=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},a.prototype.listeners=function(t){return h(this,t,!0)},a.prototype.rawListeners=function(t){return h(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},a.prototype.listenerCount=d,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(36),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(2))},function(t,e,n){(function(t){function n(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===n(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===n(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===n(t)},e.isError=function(t){return"[object Error]"===n(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,n(0).Buffer)},function(t,e,n){(function(t){var r=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,t,r.depth)}function s(t,e){var n=a.styles[e];return n?"["+a.colors[n][0]+"m"+t+"["+a.colors[n][1]+"m":t}function c(t,e){return t}function f(t,n,r){if(t.customInspect&&n&&E(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=f(t,i,r)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(y(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,n);if(o)return o;var u=Object.keys(n),a=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(n)),S(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return l(n);if(0===u.length){if(E(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(b(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(_(n))return t.stylize(Date.prototype.toString.call(n),"date");if(S(n))return l(n)}var c,w="",x=!1,T=["{","}"];(h(n)&&(x=!0,T=["[","]"]),E(n))&&(w=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(w=" "+RegExp.prototype.toString.call(n)),_(n)&&(w=" "+Date.prototype.toUTCString.call(n)),S(n)&&(w=" "+l(n)),0!==u.length||x&&0!=n.length?r<0?b(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),c=x?function(t,e,n,r,i){for(var o=[],u=0,a=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(c,w,T)):T[0]+w+T[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,n,r,i,o){var u,a,s;if((s=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(a=t.stylize("[Setter]","special")),R(r,i)||(u="["+i+"]"),a||(t.seen.indexOf(s.value)<0?(a=g(n)?f(t,s.value,null):f(t,s.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),m(u)){if(o&&i.match(/^\d+$/))return a;(u=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+a}function h(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return void 0===t}function b(t){return w(t)&&"[object RegExp]"===x(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===x(t)}function S(t){return w(t)&&("[object Error]"===x(t)||t instanceof Error)}function E(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(m(o)&&(o=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!u[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=t.pid;u[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else u[n]=function(){};return u[n]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=d,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=y,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=b,e.isObject=w,e.isDate=_,e.isError=S,e.isFunction=E,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(56);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",k(),e.format.apply(e,arguments))},e.inherits=n(3),e._extend=function(t,e){if(!e||!w(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function P(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(O&&t[O]){var e;if("function"!=typeof(e=t[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,O,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),i=[],o=0;o-1&&t%1==0&&t<=U}function z(t){return null!=t&&N(t.length)&&!function(t){if(!s(t))return!1;var e=D(t);return e==j||e==L||e==I||e==B}(t)}var F={};function q(){}function G(t){return function(){if(null!==t){var e=t;t=null,e.apply(this,arguments)}}}var Y="function"==typeof Symbol&&Symbol.iterator,K=function(t){return Y&&t[Y]&&t[Y]()};function W(t){return null!=t&&"object"==typeof t}var H="[object Arguments]";function V(t){return W(t)&&D(t)==H}var $=Object.prototype,Q=$.hasOwnProperty,J=$.propertyIsEnumerable,Z=V(function(){return arguments}())?V:function(t){return W(t)&&Q.call(t,"callee")&&!J.call(t,"callee")},X=Array.isArray,tt="object"==typeof e&&e&&!e.nodeType&&e,et=tt&&"object"==typeof i&&i&&!i.nodeType&&i,nt=et&&et.exports===tt?E.Buffer:void 0,rt=(nt?nt.isBuffer:void 0)||function(){return!1},it=9007199254740991,ot=/^(?:0|[1-9]\d*)$/;function ut(t,e){return!!(e=null==e?it:e)&&("number"==typeof t||ot.test(t))&&t>-1&&t%1==0&&t2&&(r=o(arguments,1)),e){var c={};Ft(i,(function(t,e){c[e]=t})),c[t]=r,a=!0,s=Object.create(null),n(e,c)}else i[t]=r,d(t)}));u++;var c=b(e[e.length-1]);e.length>1?c(i,r):c(r)}}(t,e)}))}function h(){if(0===c.length&&0===u)return n(null,i);for(;c.length&&u=0&&n.push(r)})),n}Ft(t,(function(e,n){if(!X(e))return p(n,[e]),void f.push(n);var r=e.slice(0,e.length-1),i=r.length;if(0===i)return p(n,e),void f.push(n);l[n]=i,Ut(r,(function(o){if(!t[o])throw new Error("async.auto task `"+n+"` has a non-existent dependency `"+o+"` in "+r.join(", "));var u,a,c;a=function(){0==--i&&p(n,e)},(c=s[u=o])||(c=s[u]=[]),c.push(a)}))})),function(){for(var t,e=0;f.length;)t=f.pop(),e++,Ut(g(t),(function(t){0==--l[t]&&f.push(t)}));if(e!==r)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),h()};function Kt(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n=r?t:function(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=Array(i);++r-1;);return n}(i,o),function(t,e){for(var n=t.length;n--&&Gt(e,t[n],0)>-1;);return n}(i,o)+1).join("")}var pe=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,he=/,/,de=/(=.+)?(\s*)$/,ge=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function ye(t,e){var n={};Ft(t,(function(t,e){var r,i=m(t),o=!i&&1===t.length||i&&0===t.length;if(X(t))r=t.slice(0,-1),t=t[t.length-1],n[e]=r.concat(r.length>0?u:t);else if(o)n[e]=t;else{if(r=function(t){return t=(t=(t=(t=t.toString().replace(ge,"")).match(pe)[2].replace(" ",""))?t.split(he):[]).map((function(t){return le(t.replace(de,""))}))}(t),0===t.length&&!i&&0===r.length)throw new Error("autoInject task functions require explicit parameters.");i||r.pop(),n[e]=r.concat(u)}function u(e,n){var i=Kt(r,(function(t){return e[t]}));i.push(n),b(t).apply(null,i)}})),Yt(n,e)}function ve(){this.head=this.tail=null,this.length=0}function me(t,e){t.length=1,t.head=t.tail=e}function be(t,e,n){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var r=b(t),i=0,o=[],u=!1;function a(t,e,n){if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");if(f.started=!0,X(t)||(t=[t]),0===t.length&&f.idle())return h((function(){f.drain()}));for(var r=0,i=t.length;r0&&o.splice(a,1),u.callback.apply(u,arguments),null!=e&&f.error(e,u.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new ve,concurrency:e,payload:n,saturated:q,unsaturated:q,buffer:e/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(t,e){a(t,!1,e)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(t,e){a(t,!0,e)},remove:function(t){f._tasks.remove(t)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(i=o(arguments,1)),r[e]=i,n(t)}))}),(function(t){n(t,r)}))}function vn(t,e){yn(Ot,t,e)}function mn(t,e,n){yn(xt(e),t,n)}var bn=function(t,e){var n=b(t);return be((function(t,e){n(t[0],e)}),e,1)},wn=function(t,e){var n=bn(t,e);return n.push=function(t,e,r){if(null==r&&(r=q),"function"!=typeof r)throw new Error("task callback must be a function");if(n.started=!0,X(t)||(t=[t]),0===t.length)return h((function(){n.drain()}));e=e||0;for(var i=n._tasks.head;i&&e>=i.priority;)i=i.next;for(var o=0,u=t.length;or?1:0}Mt(t,(function(t,e){r(t,(function(n,r){if(n)return e(n);e(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,Kt(e.sort(i),Je("value")))}))}function Bn(t,e,n){var r=b(t);return a((function(i,o){var u,a=!1;i.push((function(){a||(o.apply(null,arguments),clearTimeout(u))})),u=setTimeout((function(){var e=t.name||"anonymous",r=new Error('Callback function "'+e+'" timed out.');r.code="ETIMEDOUT",n&&(r.info=n),a=!0,o(r)}),e),r.apply(null,i)}))}var Un=Math.ceil,Nn=Math.max;function zn(t,e,n,r){var i=b(n);jt(function(t,e,n,r){for(var i=-1,o=Nn(Un((e-t)/(n||1)),0),u=Array(o);o--;)u[r?o:++i]=t,t+=n;return u}(0,t,1),e,i,r)}var Fn=At(zn,1/0),qn=At(zn,1);function Gn(t,e,n,r){arguments.length<=3&&(r=n,n=e,e=X(t)?[]:{}),r=G(r||q);var i=b(n);Ot(t,(function(t,n,r){i(e,t,n,r)}),(function(t){r(t,e)}))}function Yn(t,e){var n,r=null;e=e||q,Ke(t,(function(t,e){b(t)((function(t,i){n=arguments.length>2?o(arguments,1):i,r=t,e(!t)}))}),(function(){e(r,n)}))}function Kn(t){return function(){return(t.unmemoized||t).apply(null,arguments)}}function Wn(t,e,n){n=Et(n||q);var r=b(e);if(!t())return n(null);var i=function(e){if(e)return n(e);if(t())return r(i);var u=o(arguments,1);n.apply(null,[null].concat(u))};r(i)}function Hn(t,e,n){Wn((function(){return!t.apply(this,arguments)}),e,n)}var Vn=function(t,e){if(e=G(e||q),!X(t))return e(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return e();var n=0;function r(e){var r=b(t[n++]);e.push(Et(i)),r.apply(null,e)}function i(i){if(i||n===t.length)return e.apply(null,arguments);r(o(arguments,1))}r([])},$n={apply:u,applyEach:Dt,applyEachSeries:Bt,asyncify:d,auto:Yt,autoInject:ye,cargo:we,compose:xe,concat:ke,concatLimit:Ae,concatSeries:Re,constant:Oe,detect:De,detectLimit:Ie,detectSeries:je,dir:Be,doDuring:Ue,doUntil:ze,doWhilst:Ne,during:Fe,each:Ge,eachLimit:Ye,eachOf:Ot,eachOfLimit:Tt,eachOfSeries:_e,eachSeries:Ke,ensureAsync:We,every:Ve,everyLimit:$e,everySeries:Qe,filter:en,filterLimit:nn,filterSeries:rn,forever:on,groupBy:an,groupByLimit:un,groupBySeries:sn,log:cn,map:Mt,mapLimit:jt,mapSeries:Lt,mapValues:ln,mapValuesLimit:fn,mapValuesSeries:pn,memoize:dn,nextTick:gn,parallel:vn,parallelLimit:mn,priorityQueue:wn,queue:bn,race:_n,reduce:Se,reduceRight:Sn,reflect:En,reflectAll:xn,reject:An,rejectLimit:kn,rejectSeries:Rn,retry:Pn,retryable:Cn,seq:Ee,series:Mn,setImmediate:h,some:Dn,someLimit:In,someSeries:jn,sortBy:Ln,timeout:Bn,times:Fn,timesLimit:zn,timesSeries:qn,transform:Gn,tryEach:Yn,unmemoize:Kn,until:Hn,waterfall:Vn,whilst:Wn,all:Ve,allLimit:$e,allSeries:Qe,any:Dn,anyLimit:In,anySeries:jn,find:De,findLimit:Ie,findSeries:je,forEach:Ge,forEachSeries:Ke,forEachLimit:Ye,forEachOf:Ot,forEachOfSeries:_e,forEachOfLimit:Tt,inject:Se,foldl:Se,foldr:Sn,select:en,selectLimit:nn,selectSeries:rn,wrapSync:d};e.default=$n,e.apply=u,e.applyEach=Dt,e.applyEachSeries=Bt,e.asyncify=d,e.auto=Yt,e.autoInject=ye,e.cargo=we,e.compose=xe,e.concat=ke,e.concatLimit=Ae,e.concatSeries=Re,e.constant=Oe,e.detect=De,e.detectLimit=Ie,e.detectSeries=je,e.dir=Be,e.doDuring=Ue,e.doUntil=ze,e.doWhilst=Ne,e.during=Fe,e.each=Ge,e.eachLimit=Ye,e.eachOf=Ot,e.eachOfLimit=Tt,e.eachOfSeries=_e,e.eachSeries=Ke,e.ensureAsync=We,e.every=Ve,e.everyLimit=$e,e.everySeries=Qe,e.filter=en,e.filterLimit=nn,e.filterSeries=rn,e.forever=on,e.groupBy=an,e.groupByLimit=un,e.groupBySeries=sn,e.log=cn,e.map=Mt,e.mapLimit=jt,e.mapSeries=Lt,e.mapValues=ln,e.mapValuesLimit=fn,e.mapValuesSeries=pn,e.memoize=dn,e.nextTick=gn,e.parallel=vn,e.parallelLimit=mn,e.priorityQueue=wn,e.queue=bn,e.race=_n,e.reduce=Se,e.reduceRight=Sn,e.reflect=En,e.reflectAll=xn,e.reject=An,e.rejectLimit=kn,e.rejectSeries=Rn,e.retry=Pn,e.retryable=Cn,e.seq=Ee,e.series=Mn,e.setImmediate=h,e.some=Dn,e.someLimit=In,e.someSeries=jn,e.sortBy=Ln,e.timeout=Bn,e.times=Fn,e.timesLimit=zn,e.timesSeries=qn,e.transform=Gn,e.tryEach=Yn,e.unmemoize=Kn,e.until=Hn,e.waterfall=Vn,e.whilst=Wn,e.all=Ve,e.allLimit=$e,e.allSeries=Qe,e.any=Dn,e.anyLimit=In,e.anySeries=jn,e.find=De,e.findLimit=Ie,e.findSeries=je,e.forEach=Ge,e.forEachSeries=Ke,e.forEachLimit=Ye,e.forEachOf=Ot,e.forEachOfSeries=_e,e.forEachOfLimit=Tt,e.inject=Se,e.foldl=Se,e.foldr=Sn,e.select=en,e.selectLimit=nn,e.selectSeries=rn,e.wrapSync=d,Object.defineProperty(e,"__esModule",{value:!0})})(e)}).call(this,n(7).setImmediate,n(1),n(2),n(37)(t))},function(t,e,n){(function(e){var r=n(21),i=n(22),o={_parseHex:function(t){try{var n;return n="string"==typeof t?r.readFileSync(t,{encoding:"utf8"}):e.from(t),i.parse(n).data}catch(t){return t}},_hexStringToByte:function(t){return e.from([parseInt(t,16)])}};t.exports=o}).call(this,n(0).Buffer)},function(t,e,n){var r=n(0).Buffer;t.exports=function(t,e){if(r.isBuffer(t)&&r.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var n=0;n-1?r:o.nextTick;m.WritableState=v;var c=n(8);c.inherits=n(3);var f={deprecate:n(67)},l=n(26),p=n(11).Buffer,h=i.Uint8Array||function(){};var d,g=n(27);function y(){}function v(t,e){a=a||n(4),t=t||{};var r=e instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?(o.nextTick(i,r),o.nextTick(x,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(i(r),t._writableState.errorEmitted=!0,t.emit("error",r),x(t,e))}(t,n,r,e,i);else{var u=S(n);u||n.corked||n.bufferProcessing||!n.bufferedRequest||_(t,n),r?s(w,t,n,u,i):w(t,n,u,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new u(this)}function m(t){if(a=a||n(4),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new v(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function b(t,e,n,r,i,o,u){e.writelen=r,e.writecb=u,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function w(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),x(t,e)}function _(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)i[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;i.allBuffers=s,b(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new u(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(b(t,e,!1,e.objectMode?1:c.length,c,f,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final((function(n){e.pendingcb--,n&&t.emit("error",n),e.prefinished=!0,t.emit("prefinish"),x(t,e)}))}function x(t,e){var n=S(e);return n&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}c.inherits(m,l),v.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(v.prototype,"buffer",{get:f.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof v)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,n){var r,i=this._writableState,u=!1,a=!i.objectMode&&(r=t,p.isBuffer(r)||r instanceof h);return a&&!p.isBuffer(t)&&(t=function(t){return p.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=y),i.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),o.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var i=!0,u=!1;return null===n?u=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||e.objectMode||(u=new TypeError("Invalid non-string/buffer chunk")),u&&(t.emit("error",u),o.nextTick(r,u),i=!1),i}(this,i,t,n))&&(i.pendingcb++,u=function(t,e,n,r,i,o){if(!n){var u=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=p.from(e,n));return e}(e,r,i);r!==u&&(n=!0,i="buffer",r=u)}var a=e.objectMode?1:r.length;e.length+=a;var s=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,x(t,e),n&&(e.finished?o.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=g.destroy,m.prototype._undestroy=g.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,n(1),n(7).setImmediate,n(2))},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){},function(t,e,n){(function(t){e.parse=function(e,n){e instanceof t&&(e=e.toString("ascii"));var r=new t(n||8192),i=0,o=0,u=null,a=null,s=0,c=0;for(;c+11<=e.length;){if(":"!=e.charAt(c++))throw new Error("Line "+(s+1)+" does not start with a colon (:).");s++;var f=parseInt(e.substr(c,2),16);c+=2;var l=parseInt(e.substr(c,4),16);c+=4;var p=parseInt(e.substr(c,2),16);c+=2;var h=e.substr(c,2*f),d=new t(h,"hex");c+=2*f;var g=parseInt(e.substr(c,2),16);c+=2;for(var y=f+(l>>8)+l+p&255,v=0;v=r.length){var b=new t(2*(m+f));r.copy(b,0,0,i),r=b}m>i&&r.fill(255,i,m),d.copy(r,m),i=Math.max(i,m+f);break;case 1:if(0!=f)throw new Error("Invalid EOF record on line "+s+".");return{data:r.slice(0,i),startSegmentAddress:u,startLinearAddress:a};case 2:if(2!=f||0!=l)throw new Error("Invalid extended segment address record on line "+s+".");o=parseInt(h,16)<<4;break;case 3:if(4!=f||0!=l)throw new Error("Invalid start segment address record on line "+s+".");u=parseInt(h,16);break;case 4:if(2!=f||0!=l)throw new Error("Invalid extended linear address record on line "+s+".");o=parseInt(h,16)<<16;break;case 5:if(4!=f||0!=l)throw new Error("Invalid start linear address record on line "+s+".");a=parseInt(h,16);break;default:throw new Error("Invalid record type ("+p+") on line "+s)}"\r"==e.charAt(c)&&c++,"\n"==e.charAt(c)&&c++}throw new Error("Unexpected end of input: missing or invalid EOF record.")}}).call(this,n(0).Buffer)},function(t,e){function n(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}n.keys=function(){return[]},n.resolve=n,t.exports=n,n.id=23},function(t,e){t.exports.MESSAGE_START=27,t.exports.TOKEN=14,t.exports.CMD_SIGN_ON=1,t.exports.CMD_SET_PARAMETER=2,t.exports.CMD_GET_PARAMETER=3,t.exports.CMD_SET_DEVICE_PARAMETERS=4,t.exports.CMD_OSCCAL=5,t.exports.CMD_LOAD_ADDRESS=6,t.exports.CMD_FIRMWARE_UPGRADE=7,t.exports.CMD_ENTER_PROGMODE_ISP=16,t.exports.CMD_LEAVE_PROGMODE_ISP=17,t.exports.CMD_CHIP_ERASE_ISP=18,t.exports.CMD_PROGRAM_FLASH_ISP=19,t.exports.CMD_READ_FLASH_ISP=20,t.exports.CMD_PROGRAM_EEPROM_ISP=21,t.exports.CMD_READ_EEPROM_ISP=22,t.exports.CMD_PROGRAM_FUSE_ISP=23,t.exports.CMD_READ_FUSE_ISP=24,t.exports.CMD_PROGRAM_LOCK_ISP=25,t.exports.CMD_READ_LOCK_ISP=26,t.exports.CMD_READ_SIGNATURE_ISP=27,t.exports.CMD_READ_OSCCAL_ISP=28,t.exports.CMD_SPI_MULTI=29,t.exports.CMD_ENTER_PROGMODE_PP=32,t.exports.CMD_LEAVE_PROGMODE_PP=33,t.exports.CMD_CHIP_ERASE_PP=34,t.exports.CMD_PROGRAM_FLASH_PP=35,t.exports.CMD_READ_FLASH_PP=36,t.exports.CMD_PROGRAM_EEPROM_PP=37,t.exports.CMD_READ_EEPROM_PP=38,t.exports.CMD_PROGRAM_FUSE_PP=39,t.exports.CMD_READ_FUSE_PP=40,t.exports.CMD_PROGRAM_LOCK_PP=41,t.exports.CMD_READ_LOCK_PP=42,t.exports.CMD_READ_SIGNATURE_PP=43,t.exports.CMD_READ_OSCCAL_PP=44,t.exports.CMD_SET_CONTROL_STACK=45,t.exports.CMD_ENTER_PROGMODE_HVSP=48,t.exports.CMD_LEAVE_PROGMODE_HVSP=49,t.exports.CMD_CHIP_ERASE_HVSP=50,t.exports.CMD_PROGRAM_FLASH_HVSP=51,t.exports.CMD_READ_FLASH_HVSP=52,t.exports.CMD_PROGRAM_EEPROM_HVSP=53,t.exports.CMD_READ_EEPROM_HVSP=54,t.exports.CMD_PROGRAM_FUSE_HVSP=55,t.exports.CMD_READ_FUSE_HVSP=56,t.exports.CMD_PROGRAM_LOCK_HVSP=57,t.exports.CMD_READ_LOCK_HVSP=58,t.exports.CMD_READ_SIGNATURE_HVSP=59,t.exports.CMD_READ_OSCCAL_HVSP=60,t.exports.STATUS_CMD_OK=0,t.exports.STATUS_CMD_TOUT=128,t.exports.STATUS_RDY_BSY_TOUT=129,t.exports.STATUS_SET_PARAM_MISSING=130,t.exports.STATUS_CMD_FAILED=192,t.exports.STATUS_CKSUM_ERROR=193,t.exports.STATUS_CMD_UNKNOWN=201,t.exports.STATUS_BUILD_NUMBER_LOW=128,t.exports.STATUS_BUILD_NUMBER_HIGH=129,t.exports.STATUS_HW_VER=144,t.exports.STATUS_SW_MAJOR=145,t.exports.STATUS_SW_MINOR=146,t.exports.STATUS_VTARGET=148,t.exports.STATUS_VADJUST=149,t.exports.STATUS_OSC_PSCALE=150,t.exports.STATUS_OSC_CMATCH=151,t.exports.STATUS_SCK_DURATION=152,t.exports.STATUS_TOPCARD_DETECT=154,t.exports.STATUS_STATUS=156,t.exports.STATUS_DATA=157,t.exports.STATUS_RESET_POLARITY=158,t.exports.STATUS_CONTROLLER_INIT=159,t.exports.ANSWER_CKSUM_ERROR=176},function(t,e,n){"use strict";(function(e,r){var i=n(10);t.exports=b;var o,u=n(20);b.ReadableState=m;n(6).EventEmitter;var a=function(t,e){return t.listeners(e).length},s=n(26),c=n(11).Buffer,f=e.Uint8Array||function(){};var l=n(8);l.inherits=n(3);var p=n(64),h=void 0;h=p&&p.debuglog?p.debuglog("stream"):function(){};var d,g=n(65),y=n(27);l.inherits(b,s);var v=["error","close","destroy","pause","resume"];function m(t,e){t=t||{};var r=e instanceof(o=o||n(4));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,u=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(u||0===u)?u:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(28).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function b(t){if(o=o||n(4),!(this instanceof b))return new b(t);this._readableState=new m(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function w(t,e,n,r,i){var o,u=t._readableState;null===e?(u.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,x(t)}(t,u)):(i||(o=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(u,e)),o?t.emit("error",o):u.objectMode||e&&e.length>0?("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?u.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,u,e,!0):u.ended?t.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!n?(e=u.decoder.write(e),u.objectMode||0!==e.length?_(t,u,e,!1):A(t,u)):_(t,u,e,!1))):r||(u.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=S?t=S:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(h("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(T,t):T(t))}function T(t){h("emit readable"),t.emit("readable"),P(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;to.length?o.length:t;if(u===o.length?i+=o:i+=o.slice(0,t),0===(t-=u)){u===o.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(u));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var o=r.data,u=t>o.length?o.length:t;if(o.copy(n,n.length-t,0,u),0===(t-=u)){u===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(u));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function I(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return h("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):x(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return h("need readable",i),(0===e.length||e.length-t0?C(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:b;function c(e,r){h("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,h("cleanup"),t.removeListener("close",v),t.removeListener("finish",m),t.removeListener("drain",l),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",b),n.removeListener("data",g),p=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){h("onend"),t.end()}o.endEmitted?i.nextTick(s):n.once("end",s),t.on("unpipe",c);var l=function(t){return function(){var e=t._readableState;h("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",l);var p=!1;var d=!1;function g(e){h("ondata"),d=!1,!1!==t.write(e)||d||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==I(o.pipes,t))&&!p&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){h("onerror",e),b(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",m),b()}function m(){h("onfinish"),t.removeListener("close",v),b()}function b(){h("unpipe"),n.unpipe(t)}return n.on("data",g),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?u(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",v),t.once("finish",m),t.emit("pipe",n),o.flowing||(h("pipe resume"),n.resume()),t},b.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function s(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function f(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function p(t){return t.toString(this.encoding)}function h(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(t.lastNeed=i-1),i;if(--r=0)return i>0&&(t.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,n){"use strict";t.exports=u;var r=n(4),i=n(8);function o(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length0?u-4:u;for(n=0;n>16&255,s[f++]=e>>8&255,s[f++]=255&e;2===a&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,s[f++]=255&e);1===a&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,s[f++]=e>>8&255,s[f++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],u=0,a=n-i;ua?a:u+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=u.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t,e,n){for(var i,o,u=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return u.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,i){var o,u,a=8*i-r-1,s=(1<>1,f=-7,l=n?i-1:0,p=n?-1:1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=p,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=r;f>0;u=256*u+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===s)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),o-=c}return(h?-1:1)*u*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var u,a,s,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=f):(u=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-u))<1&&(u--,s*=2),(e+=u+l>=1?p/s:p*Math.pow(2,1-l))*s>=2&&(u++,s/=2),u+l>=f?(a=0,u=f):u+l>=1?(a=(e*s-1)*Math.pow(2,i),u+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),u=0));i>=8;t[n+h]=255&a,h+=d,a/=256,i-=8);for(u=u<0;t[n+h]=255&u,h+=d,u/=256,c-=8);t[n+h-d]|=128*g}},function(t,e,n){var r=n(35),i=n(12),o=n(38),u=(n(13),function(t){this.options=t,this.debug=this.options.debug?console.log.bind(console):function(){},this.board=this.options.board});u.prototype._init=function(t){this._setUpSerial((function(e){return t(e)}))},u.prototype._setUpSerial=function(t){return this.serialPort=new r("",{baudRate:this.board.baud,autoOpen:!1}),t(null)},u.prototype._sniffPort=function(t){var e=this.board.productId.map((function(t){return parseInt(t,16)}));this._listPorts((function(n,r){var i=r.filter((function(t){return-1!==e.indexOf(parseInt(t._standardPid,16))}));return t(null,i)}))},u.prototype._setDTR=function(t,e,n){var r={rts:t,dtr:t};this.serialPort.set(r,(function(t){if(t)return n(t);setTimeout((function(){n(t)}),e)}))},u.prototype._pollForPort=function(t){var e=this,n=o((function(t){var n=!1;e._sniffPort((function(r,i){i.length&&(e.options.port=i[0].comName,n=!0),t(n)}))}));n.every(100).ask(15),n((function(n){if(!n)return t(new Error("could not reconnect after resetting board."));e.debug("found port on",e.options.port),e._setUpSerial((function(e){return t(e)}))}))},u.prototype._pollForOpen=function(t){var e=this,n=o((function(t){e.serialPort.open((function(e){t(!e)}))}));n.every(200).ask(10),n((function(n){var r;n||(r=new Error("could not open board on "+e.serialPort.path)),t(r)}))},u.prototype._cycleDTR=function(t){i.series([this._setDTR.bind(this,!0,250),this._setDTR.bind(this,!1,50)],(function(e){return t(e)}))},u.prototype._listPorts=function(t){var e=[];r.list((function(n,r){if(n)return t(n);for(var i=0;it(null,e)).catch(e=>t(e))}open(t){navigator.serial.requestPort(this.requestOptions).then(t=>(this.port=t,this.port.open({baudrate:this.baudrate||57600}))).then(()=>this.writer=this.port.writable.getWriter()).then(()=>this.reader=this.port.readable.getReader()).then(async()=>{for(this.emit("open"),t(null);this.port.readable;)try{for(;;){const{value:t,done:n}=await this.reader.read();if(n)break;this.emit("data",e.from(t))}}catch(t){console.log("ERROR while reading port:",t)}}).catch(e=>{t(e)})}close(t){if(this.port.close(),t)return t(null)}set(t,e){this.port.setSignals(t).then(()=>e(null)).catch(t=>e(t))}write(t,e){return this.writer.write(t),e(null)}read(t){this.reader.read().then(e=>t(null,e)).catch(e=>t(e))}flush(){this.port.flush()}}}).call(this,n(0).Buffer)},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,u,a,s=1,c={},f=!1,l=t.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(t);p=p&&p.setTimeout?p:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){o.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(t){var e=l.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(u="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(u)&&d(+e.data.slice(u.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),r=function(e){t.postMessage(u+e,"*")}),p.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=o?n&&(n=null,r(!!t)):(u&&(!0===u?e=i(e,c):e+=c*u),s=setTimeout(f,e))}return(e=function(t){if(s&&(clearTimeout(s),s=null,n&&n(!1),n=null,c=0),arguments.length){if(!r(t,"function"))throw new TypeError("done callback must be a function");n=t}s=setTimeout(f,a)}).ask=function(t){if(s)throw new SyntaxError("can not set ask limit during polling");if(!r(t,"number"))throw new TypeError("ask limit must be a number");return o=t,e},e.every=function(t){if(s)throw new SyntaxError("can not set timeout during polling");if(!r(t,"number"))throw new TypeError("timout must be a number");return a=t,e},e.incr=function(t){if(s)throw new SyntexError("can not set increment during polling");if(!arguments.length||r(t,"boolean"))u=!!t;else{if(!r(t,"number"))throw new TypeError("increment must be a boolean or number");u=t}return e},e}()}},function(t,e){t.exports=function(t,e){function n(e){return"object"==typeof t&&null!==t}function r(t){return t.name.toLowerCase()}switch(2===arguments.length&&void 0===e?e="undefined":Number.isNaN(e)&&(e="NaN"),e){case"boolean":case"function":case"string":return typeof t===e;case"number":return typeof t===e&&!isNaN(t);case Number:if(isNaN(t))return!1;case String:case Boolean:return typeof t===r(e);case Object:case"object":return n();case"array":return Array.isArray(t);case"regex":case"regexp":return t instanceof RegExp;case"date":return t instanceof Date;case"null":case null:return null===t;case"undefined":return void 0===t;case"NaN":return Number.isNaN(t);case"arguments":return!!n()&&("function"==typeof t.callee||/arguments/i.test(t.toString()));default:return"function"==typeof e?t instanceof e:t}}},function(t,e){t.exports=function(t,e){for(var n=0;n++>8&255,c={cmd:[i.Cmnd_STK_LOAD_ADDRESS,a,s],responseData:i.OK_RESPONSE,timeout:n};o(t,c,(function(t,e){u.log("loaded address",t,e),r(t,e)}))},u.prototype.loadPage=function(t,n,r,u){this.log("load page");var a=this,s=255&n.length,c=n.length>>8,f={cmd:e.concat([new e([i.Cmnd_STK_PROG_PAGE,c,s,70]),n,new e([i.Sync_CRC_EOP])]),responseData:i.OK_RESPONSE,timeout:r};o(t,f,(function(t,e){a.log("loaded page",t,e),u(t,e)}))},u.prototype.upload=function(t,e,n,i,o){this.log("program");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.loadPage(t,u,i,e)},function(t){c.log("programmed page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("page done"),o(t)}))}),(function(t){c.log("upload done"),o(t)}))},u.prototype.exitProgrammingMode=function(t,e,n){this.log("send leave programming mode");var r=this,u={cmd:[i.Cmnd_STK_LEAVE_PROGMODE],responseData:i.OK_RESPONSE,timeout:e};o(t,u,(function(t,e){r.log("sent leave programming mode",t,e),n(t,e)}))},u.prototype.verify=function(t,e,n,i,o){this.log("verify");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.verifyPage(t,u,n,i,e)},function(t){c.log("verified page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("verify done"),o(t)}))}),(function(t){c.log("verify done"),o(t)}))},u.prototype.verifyPage=function(t,n,r,u,a){this.log("verify page");var s=this;match=e.concat([new e([i.Resp_STK_INSYNC]),n,new e([i.Resp_STK_OK])]);var c=n.length>=r?r:n.length,f={cmd:[i.Cmnd_STK_READ_PAGE,c>>8&255,255&c,70],responseLength:match.length,timeout:u};o(t,f,(function(t,e){s.log("confirm page",t,e,e.toString("hex")),a(t,e)}))},u.prototype.bootload=function(t,e,n,i){var o={pagesizehigh:n.pagesizehigh<<8&255,pagesizelow:255&n.pagesizelow};r.series([this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.verifySignature.bind(this,t,n.signature,n.timeout),this.setOptions.bind(this,t,o,n.timeout),this.enterProgrammingMode.bind(this,t,n.timeout),this.upload.bind(this,t,e,n.pageSize,n.timeout),this.verify.bind(this,t,e,n.pageSize,n.timeout),this.exitProgrammingMode.bind(this,t,n.timeout)],(function(t){return i(t)}))},t.exports=u}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i;!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e){var r=n(14),i=n(46),o=n(15);t.exports=function(t,n,u){var a,s=n.timeout||0,c=(o.Resp_STK_INSYNC,o.Resp_STK_NOSYNC,null),f=0;n.responseData&&n.responseData.length>0&&(c=n.responseData),c&&(f=c.length),n.responseLength&&(f=n.responseLength);var l=n.cmd;l instanceof Array&&(l=new e(l.concat(o.Sync_CRC_EOP))),t.write(l,(function(e){if(e)return a=new Error("Sending "+l.toString("hex")+": "+e.message),u(a);i(t,s,f,(function(t,e){return t?(a=new Error("Sending "+l.toString("hex")+": "+t.message),u(a)):c&&!r(e,c)?(a=new Error(l+" response mismatch: "+e.toString("hex")+", "+c.toString("hex")),u(a)):void u(null,e)}))}))}}).call(this,n(0).Buffer)},function(t,e,n){(function(e){var r=[n(15).Resp_STK_INSYNC];t.exports=function(t,n,i,o){var u=new e(0),a=!1,s=null,c=function(t){for(var n=0;!a&&ni)return f(new Error("buffer overflow "+u.length+" > "+i));u.length==i&&f()},f=function(e){s&&clearTimeout(s),t.removeListener("data",c),o(e,u)};n&&n>0&&(s=setTimeout((function(){s=null,f(new Error("receiveData timeout after "+n+"ms"))}),n)),t.on("data",c)}}).call(this,n(0).Buffer)},function(t,e){var n={};t.exports=n;var r={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(r).forEach((function(t){var e=r[t],i=n[t]=[];i.open="["+e[0]+"m",i.close="["+e[1]+"m"}))},function(t,e,n){(function(e){var n=e.argv;t.exports=!(-1!==n.indexOf("--no-color")||-1!==n.indexOf("--color=false")||-1===n.indexOf("--color")&&-1===n.indexOf("--color=true")&&-1===n.indexOf("--color=always")&&(e.stdout&&!e.stdout.isTTY||"win32"!==e.platform&&!("COLORTERM"in e.env||"dumb"!==e.env.TERM&&/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(e.env.TERM))))}).call(this,n(1))},function(t,e){t.exports=function(t,e){var n="";t=(t=t||"Run the trap, drop the bass").split("");var r={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","۝","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return t.forEach((function(t){t=t.toLowerCase();var e=r[t]||[" "],i=Math.floor(Math.random()*e.length);n+=void 0!==r[t]?r[t][i]:t})),n}},function(t,e){t.exports=function(t,e){t=t||" he is here ";var n={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},r=[].concat(n.up,n.down,n.mid);function i(t){return Math.floor(Math.random()*t)}function o(t){var e=!1;return r.filter((function(n){e=n===t})),e}return function(t,e){var r,u,a="";for(u in(e=e||{}).up=void 0===e.up||e.up,e.mid=void 0===e.mid||e.mid,e.down=void 0===e.down||e.down,e.size=void 0!==e.size?e.size:"maxi",t=t.split(""))if(!o(u)){switch(a+=t[u],r={up:0,down:0,mid:0},e.size){case"mini":r.up=i(8),r.mid=i(2),r.down=i(8);break;case"maxi":r.up=i(16)+3,r.mid=i(4)+1,r.down=i(64)+3;break;default:r.up=i(8)+1,r.mid=i(6)/2,r.down=i(8)+1}var s=["up","mid","down"];for(var c in s)for(var f=s[c],l=0;l<=r[f];l++)e[f]&&(a+=n[f][i(n[f].length)])}return a}(t,e)}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){if(" "===t)return t;switch(e%3){case 0:return r.red(t);case 1:return r.white(t);case 2:return r.blue(t)}}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){return e%2==0?t:r.inverse(t)}},function(t,e,n){var r,i=n(5);t.exports=(r=["red","yellow","green","blue","magenta"],function(t,e,n){return" "===t?t:i[r[e++%r.length]](t)})},function(t,e,n){var r,i=n(5);t.exports=(r=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"],function(t,e,n){return" "===t?t:i[r[Math.round(Math.random()*(r.length-1))]](t)})},function(t,e,n){var r=n(5);t.exports=function(){var t=function(t,e){String.prototype.__defineGetter__(t,e)};function e(e){var n=["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","charAt","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","charCodeAt","indexOf","lastIndexof","length","localeCompare","match","replace","search","slice","split","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","trimLeft","trimRight"];Object.keys(e).forEach((function(i){-1!==n.indexOf(i)?console.log("warn: ".red+("String.prototype"+i).magenta+" is probably something you don't want to override. Ignoring style name"):"string"==typeof e[i]?(r[i]=r[e[i]],t(i,(function(){return r[e[i]](this)}))):t(i,(function(){for(var t=this,n=0;n=6){var r=n.message[5];i.writeUInt8(r,0)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,1,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,1)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,2,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,2)}t(e)}))}],(function(e){t(e,i)}))},d.prototype.enterProgrammingMode=function(t,n){var r=this,i=Array.prototype.slice.call(arguments);"function"!=typeof(n=i.pop())&&(n=null),(t="function"!=typeof t&&t||{}).timeout=t.timeout||a,t.stabDelay=t.stabDelay||s,t.cmdexeDelay=t.cmdexeDelay||c,t.synchLoops=t.synchLoops||f,t.byteDelay=t.byteDelay||l,t.pollValue=t.pollValue||p,t.pollIndex=t.pollIndex||h;var o=172,u=83,d=0,g=0,y=new e([16,t.timeout,t.stabDelay,t.cmdexeDelay,t.synchLoops,t.byteDelay,t.pollValue,t.pollIndex,o,u,d,g]);r.parser.send(y,(function(t,e){n(t)}))},d.prototype.loadAddress=function(t,n){msb=t>>24&255|128,xsb=t>>16&255,ysb=t>>8&255,lsb=255&t;var r=new e([6,msb,xsb,ysb,lsb]);this.parser.send(r,(function(t,e){n(t)}))},d.prototype.loadPage=function(t,n){var r=t.length>>8,i=255&t.length,o=new e([19,r,i,193,10,64,76,32,0,0]);o=e.concat([o,t]),this.parser.send(o,(function(t,e){n(t)}))},d.prototype.upload=function(t,e,n){var i,o,u=0,a=this;r.whilst((function(){return u>1,t()},function(t){a.loadAddress(o,t)},function(n){i=t.slice(u,t.length>e?u+e:t.length-1),n()},function(t){a.loadPage(i,t)},function(t){u+=i.length,setTimeout(t,4)}],(function(t){n(t)}))}),(function(t){n(t)}))},d.prototype.exitProgrammingMode=function(t){var n=new e([17,1,1]);this.parser.send(n,(function(e,n){t(e)}))},d.prototype.verify=function(t,e){e()},d.prototype.bootload=function(t,e,n){n()},t.exports=d}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i;!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e,r){var i=n(24),o=n(6).EventEmitter;t.exports=function(t){var n,u,a=(n=new o,u={constants:i,port:t,boundOpen:!1,closed:!1,_inc:-1,_queue:[],_current:!1,states:["Start","GetSequenceNumber","GetMessageSize1","GetMessageSize2","GetToken","GetData","GetChecksum","Done"],state:0,pkt:!1,send:function(t,n){if(this.closed)return e((function(){var t=new Error("this parser is closed.");t.code="E_CLOSED",n(t)}));r.isBuffer(t)||(t=new r(t));var o=this._commandTimeout(t[0]),u=new r([0,0]);u.writeUInt16BE(t.length,0);var a=r.concat([new r([i.MESSAGE_START,this._seq(),u[0],u[1],i.TOKEN]),t]),s=this.checksum(a);this._queue.push({buf:r.concat([a,new r([s])]),seq:this._inc,cb:n,timeout:o}),this._send()},checksum:function(t){for(var e=0,n=0;n255&&(this._inc=0),this._inc},_commandTimeout:function(t){if(timeout=1e3,t===i.CMD_SIGN_ON)timeout=200;else for(var e=Object.keys(i),n=0;n-1||e[n].indexOf("PROGRAM_FLASH")>-1||e[n].indexOf("EEPROM")>-1)&&(timeout=5e3);break}return timeout},_send:function(){if(this.closed)return!1;if(!this._current&&this._queue.length)if("function"==typeof t.isOpen?t.isOpen():t.isOpen){var e=this._queue.shift(),n=this._current={timeout:!1,seq:e.seq,cb:e.cb};this._current,this.state=0,r=this,this.port.write(e.buf),this.port.drain((function(){if(n!==r._current)return r.emit("log","current was no longer the current message after drain callback");n.timeout=setTimeout((function(){var t=new Error("stk500 timeout. "+e.timeout+"ms");t.code="E_TIMEOUT",r._resolveCurrent(t)}),e.timeout)})),this.emit("rawinput",e.buf)}else{var r=this;this.boundOpen||t.once("open",(function(){r._send()}))}},_handle:function(t){var e=this._current;if(this.emit("raw",t),!e)return this.emit("log","notice","dropping data","data");for(var n=0;n ");for(var n=0;n126)&&(r="."),e.stdout.write(r+" ["+t.readUInt8(n).toString(16)+"] ")}e.stdout.write("\n")})),this.c=function(t,e,n){return r.cmds.push({value:t,callback:function(t){e&&e(t)},expectedResponseLength:n}),this},this.flashChunkSize=0,this.bytes=[],this.cmds=[]},o.Flasher.prototype={run:function(t){var n=this;e.nextTick((function(){if(!n.running){var i=n.cmds.shift();if(i){running=!0,n.options.debug&&e.stdout.write("Send: "+i.value);var o=new r(0),u=function(a){o=r.concat([o,a]),(void 0===i.expectedResponseLength||i.expectedResponseLength<=o.length)&&(n.sp.removeListener("data",u),n.running=!1,i.callback(o),e.nextTick((function(){n.cmds.length>0?n.run(t):t&&t()})))};n.sp.on("data",u),n.sp.write(i.value)}}}))},prepare:function(t){var e=this;this.c("S",(function(n){n.toString()!==e.signature&&t(new Error("Invalid device signature; expecting: "+e.signature+" received: "+n.toString()))})).c("V").c("v").c("p").c("a").c("b",(function(n){"Y"!=(n.toString()||"X")[0]&&t(new Error("Buffered memory access not supported.")),e.flashChunkSize=n.readUInt16BE(1)})).c("t").c("TD").c("P").c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c([u("A"),3,252]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]),this.run((function(){t(null,e)}))},erase:function(t){this.c("e",(function(){t&&t()})),this.run()},program:function(t,e){var n,r=this,o=[];this.totalBytes=0,this.c([u("A"),0,0],(function(){n=i.parse(t),r.totalBytes=n.data.length,Array.prototype.push.apply(o,n.data),r.allBytes=o,r.options.debug&&console.log("programming",o.length,"bytes"),r.chunksSent=[];for(var e=0;e>8&255,255&a.length,u("F")].concat(a))}})),this.run((function(){e&&e()}))},verify:function(t){var n=this;this.c([u("A"),0,0],(function(){var r=0,i=function(o){var a=null;if(r++,n.allBytes.length){var s=o.length;if(n.allBytes.splice(0,s).forEach((function(t,e){t!==o.readUInt8(e)&&(a=new Error("Firmware on the device does not match local data"))})),a)return t(a);e.nextTick((function(){var t=n.flashChunkSize;n.options.debug&&console.log(n.totalBytes-r*n.flashChunkSize),n.totalBytes-r*n.flashChunkSize>8&255,255&t,u("F")],i,t),n.run()}))}else t&&t()};n.options.debug&&console.log("\n\nVerifying flash.."),n.c([u("g"),n.flashChunkSize>>8&255,255&n.flashChunkSize,u("F")],i,n.flashChunkSize),n.run()})),n.run()},fuseCheck:fuseCheck=function(t){this.options.debug&&console.log("checking fuses"),this.c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c("L").c("E"),this.run((function(){t()}))}},o.init=function(t,e,n){"function"!=typeof e||n||(n=e,e={}),new o.Flasher(t,e).prepare(n)}}).call(this,n(1),n(0).Buffer)},function(t,e,n){t.exports=i;var r=n(6).EventEmitter;function i(){r.call(this)}n(3)(i,r),i.Readable=n(18),i.Writable=n(69),i.Duplex=n(70),i.Transform=n(71),i.PassThrough=n(72),i.Stream=i,i.prototype.pipe=function(t,e){var n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(n.on("end",a),n.on("close",s));var u=!1;function a(){u||(u=!0,t.end())}function s(){u||(u=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===r.listenerCount(this,"error"))throw t}function f(){n.removeListener("data",i),t.removeListener("drain",o),n.removeListener("end",a),n.removeListener("close",s),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",f),n.removeListener("close",f),t.removeListener("close",f)}return n.on("error",c),t.on("error",c),n.on("end",f),n.on("close",f),t.on("close",f),t.emit("pipe",n),t}},function(t,e){},function(t,e,n){"use strict";var r=n(11).Buffer,i=n(66);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var e,n,i,o=r.allocUnsafe(t>>>0),u=this.head,a=0;u;)e=u.data,n=o,i=a,e.copy(n,i),a+=u.data.length,u=u.next;return o},t}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(2))},function(t,e,n){"use strict";t.exports=o;var r=n(29),i=n(8);function o(t){if(!(this instanceof o))return new o(t);r.call(this,t)}i.inherits=n(3),i.inherits(o,r),o.prototype._transform=function(t,e,n){n(null,t)}},function(t,e,n){t.exports=n(19)},function(t,e,n){t.exports=n(4)},function(t,e,n){t.exports=n(18).Transform},function(t,e,n){t.exports=n(18).PassThrough},function(t,e){},function(t,e){t.exports=function(t,e,n){var r=function(r){if(r=r||{},this.options={debug:r.debug||!1,board:r.board||"uno",port:r.port||"",manualReset:r.manualReset||!1},!0===this.options.debug?this.debug=console.log.bind(console):"function"==typeof this.options.debug?this.debug=this.options.debug:this.debug=function(){},"string"==typeof this.options.board?this.options.board=t[this.options.board]:"object"==typeof this.options.board&&(this.options.board=this.options.board),this.options.board&&!this.options.board.manualReset&&(this.options.board.manualReset=this.options.manualReset),this.connection=new e(this.options),this.options.board){var i=n[this.options.board.protocol]||function(){};this.protocol=new i({board:this.options.board,connection:this.connection,debug:this.debug})}};return r.prototype._validateBoard=function(t){if("object"!=typeof this.options.board)return t(new Error('"'+this.options.board+'" is not a supported board type.'));if(this.protocol.chip)return this.options.port||"pro-mini"!==this.options.board.name?t(null):t(new Error("using a pro-mini, please specify the port in your options."));var e="not a supported programming protocol: "+this.options.board.protocol;return t(new Error(e))},r.prototype.flash=function(t,e){var n=this;n._validateBoard((function(r){if(r)return e(r);n.connection._init((function(r){if(r)return e(r);n.protocol._upload(t,e)}))}))},r.prototype.listPorts=r.listPorts=r.prototype.list=r.list=function(t){return e.prototype._listPorts(t)},r.listKnownBoards=function(){return Object.keys(t).filter((function(e){var n=t[e].aliases;return!n||!~n.indexOf(e)}))},r}}]); \ No newline at end of file diff --git a/dist/avrgirl-arduino.global.min.js.LICENSE b/dist/avrgirl-arduino.global.min.js.LICENSE new file mode 100644 index 0000000..4178754 --- /dev/null +++ b/dist/avrgirl-arduino.global.min.js.LICENSE @@ -0,0 +1,14 @@ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */ diff --git a/dist/avrgirl-arduino.js b/dist/avrgirl-arduino.js new file mode 100644 index 0000000..8c4eef7 --- /dev/null +++ b/dist/avrgirl-arduino.js @@ -0,0 +1,22 @@ +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=30)}([function(t,e,n){"use strict";(function(t){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +var r=n(32),i=n(33),o=n(20);function u(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(u()=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(r)return F(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return O(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){var o,u=1,a=t.length,s=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,a/=2,s/=2,n/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(i){var f=-1;for(o=n;oa&&(n=a-s),o=n;o>=0;o--){for(var l=!0,p=0;pi&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var u=0;u>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function T(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&c)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=t[i+1],u=t[i+2],a=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&a)&&(s=(15&c)<<18|(63&o)<<12|(63&u)<<6|63&a)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=l}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0),a=Math.min(o,u),c=this.slice(r,i),f=t.slice(e,n),l=0;li)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":return _(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function R(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function I(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function j(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function L(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(t,e,n,r,o){return o||L(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return o||L(t,0,n,8),i.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=this[t],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=0,u=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=n-1,u=1,a=0;for(this[e+o]=255&t;--o>=0&&(u*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/u>>0)-a&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function q(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(2))},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,c=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?c=s.concat(c):l=-1,c.length&&h())}function h(){if(!f){var t=a(p);f=!0;for(var e=c.length;e;){for(s=c,c=[];++l1)for(var n=1;n1)for(var o=1;o0&&u.length>i&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=u.length,a=s,console&&console.warn&&console.warn(a)}return t}function l(){for(var t=[],e=0;e0&&(u=e[0]),u instanceof Error)throw u;var a=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw a.context=u,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)o(s,this,e);else{var c=s.length,f=g(s,c);for(n=0;n=0;o--)if(n[o]===e||n[o].listener===e){u=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},a.prototype.listeners=function(t){return h(this,t,!0)},a.prototype.rawListeners=function(t){return h(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},a.prototype.listenerCount=d,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(36),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(2))},function(t,e,n){(function(t){function n(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===n(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===n(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===n(t)},e.isError=function(t){return"[object Error]"===n(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,n(0).Buffer)},function(t,e,n){(function(t){var r=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,t,r.depth)}function s(t,e){var n=a.styles[e];return n?"["+a.colors[n][0]+"m"+t+"["+a.colors[n][1]+"m":t}function c(t,e){return t}function f(t,n,r){if(t.customInspect&&n&&E(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=f(t,i,r)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(y(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,n);if(o)return o;var u=Object.keys(n),a=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(n)),S(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return l(n);if(0===u.length){if(E(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(b(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(_(n))return t.stylize(Date.prototype.toString.call(n),"date");if(S(n))return l(n)}var c,w="",x=!1,T=["{","}"];(h(n)&&(x=!0,T=["[","]"]),E(n))&&(w=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(w=" "+RegExp.prototype.toString.call(n)),_(n)&&(w=" "+Date.prototype.toUTCString.call(n)),S(n)&&(w=" "+l(n)),0!==u.length||x&&0!=n.length?r<0?b(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),c=x?function(t,e,n,r,i){for(var o=[],u=0,a=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(c,w,T)):T[0]+w+T[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,n,r,i,o){var u,a,s;if((s=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(a=t.stylize("[Setter]","special")),R(r,i)||(u="["+i+"]"),a||(t.seen.indexOf(s.value)<0?(a=g(n)?f(t,s.value,null):f(t,s.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),m(u)){if(o&&i.match(/^\d+$/))return a;(u=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+a}function h(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return void 0===t}function b(t){return w(t)&&"[object RegExp]"===x(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===x(t)}function S(t){return w(t)&&("[object Error]"===x(t)||t instanceof Error)}function E(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(m(o)&&(o=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!u[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=t.pid;u[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else u[n]=function(){};return u[n]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=d,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=y,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=b,e.isObject=w,e.isDate=_,e.isError=S,e.isFunction=E,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(56);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",k(),e.format.apply(e,arguments))},e.inherits=n(3),e._extend=function(t,e){if(!e||!w(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function P(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(O&&t[O]){var e;if("function"!=typeof(e=t[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,O,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),i=[],o=0;o-1&&t%1==0&&t<=U}function z(t){return null!=t&&N(t.length)&&!function(t){if(!s(t))return!1;var e=D(t);return e==j||e==L||e==I||e==B}(t)}var F={};function q(){}function G(t){return function(){if(null!==t){var e=t;t=null,e.apply(this,arguments)}}}var Y="function"==typeof Symbol&&Symbol.iterator,K=function(t){return Y&&t[Y]&&t[Y]()};function W(t){return null!=t&&"object"==typeof t}var H="[object Arguments]";function V(t){return W(t)&&D(t)==H}var $=Object.prototype,Q=$.hasOwnProperty,J=$.propertyIsEnumerable,Z=V(function(){return arguments}())?V:function(t){return W(t)&&Q.call(t,"callee")&&!J.call(t,"callee")},X=Array.isArray,tt="object"==typeof e&&e&&!e.nodeType&&e,et=tt&&"object"==typeof i&&i&&!i.nodeType&&i,nt=et&&et.exports===tt?E.Buffer:void 0,rt=(nt?nt.isBuffer:void 0)||function(){return!1},it=9007199254740991,ot=/^(?:0|[1-9]\d*)$/;function ut(t,e){return!!(e=null==e?it:e)&&("number"==typeof t||ot.test(t))&&t>-1&&t%1==0&&t2&&(r=o(arguments,1)),e){var c={};Ft(i,(function(t,e){c[e]=t})),c[t]=r,a=!0,s=Object.create(null),n(e,c)}else i[t]=r,d(t)}));u++;var c=b(e[e.length-1]);e.length>1?c(i,r):c(r)}}(t,e)}))}function h(){if(0===c.length&&0===u)return n(null,i);for(;c.length&&u=0&&n.push(r)})),n}Ft(t,(function(e,n){if(!X(e))return p(n,[e]),void f.push(n);var r=e.slice(0,e.length-1),i=r.length;if(0===i)return p(n,e),void f.push(n);l[n]=i,Ut(r,(function(o){if(!t[o])throw new Error("async.auto task `"+n+"` has a non-existent dependency `"+o+"` in "+r.join(", "));var u,a,c;a=function(){0==--i&&p(n,e)},(c=s[u=o])||(c=s[u]=[]),c.push(a)}))})),function(){for(var t,e=0;f.length;)t=f.pop(),e++,Ut(g(t),(function(t){0==--l[t]&&f.push(t)}));if(e!==r)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),h()};function Kt(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n=r?t:function(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=Array(i);++r-1;);return n}(i,o),function(t,e){for(var n=t.length;n--&&Gt(e,t[n],0)>-1;);return n}(i,o)+1).join("")}var pe=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,he=/,/,de=/(=.+)?(\s*)$/,ge=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function ye(t,e){var n={};Ft(t,(function(t,e){var r,i=m(t),o=!i&&1===t.length||i&&0===t.length;if(X(t))r=t.slice(0,-1),t=t[t.length-1],n[e]=r.concat(r.length>0?u:t);else if(o)n[e]=t;else{if(r=function(t){return t=(t=(t=(t=t.toString().replace(ge,"")).match(pe)[2].replace(" ",""))?t.split(he):[]).map((function(t){return le(t.replace(de,""))}))}(t),0===t.length&&!i&&0===r.length)throw new Error("autoInject task functions require explicit parameters.");i||r.pop(),n[e]=r.concat(u)}function u(e,n){var i=Kt(r,(function(t){return e[t]}));i.push(n),b(t).apply(null,i)}})),Yt(n,e)}function ve(){this.head=this.tail=null,this.length=0}function me(t,e){t.length=1,t.head=t.tail=e}function be(t,e,n){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var r=b(t),i=0,o=[],u=!1;function a(t,e,n){if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");if(f.started=!0,X(t)||(t=[t]),0===t.length&&f.idle())return h((function(){f.drain()}));for(var r=0,i=t.length;r0&&o.splice(a,1),u.callback.apply(u,arguments),null!=e&&f.error(e,u.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new ve,concurrency:e,payload:n,saturated:q,unsaturated:q,buffer:e/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(t,e){a(t,!1,e)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(t,e){a(t,!0,e)},remove:function(t){f._tasks.remove(t)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(i=o(arguments,1)),r[e]=i,n(t)}))}),(function(t){n(t,r)}))}function vn(t,e){yn(Ot,t,e)}function mn(t,e,n){yn(xt(e),t,n)}var bn=function(t,e){var n=b(t);return be((function(t,e){n(t[0],e)}),e,1)},wn=function(t,e){var n=bn(t,e);return n.push=function(t,e,r){if(null==r&&(r=q),"function"!=typeof r)throw new Error("task callback must be a function");if(n.started=!0,X(t)||(t=[t]),0===t.length)return h((function(){n.drain()}));e=e||0;for(var i=n._tasks.head;i&&e>=i.priority;)i=i.next;for(var o=0,u=t.length;or?1:0}Mt(t,(function(t,e){r(t,(function(n,r){if(n)return e(n);e(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,Kt(e.sort(i),Je("value")))}))}function Bn(t,e,n){var r=b(t);return a((function(i,o){var u,a=!1;i.push((function(){a||(o.apply(null,arguments),clearTimeout(u))})),u=setTimeout((function(){var e=t.name||"anonymous",r=new Error('Callback function "'+e+'" timed out.');r.code="ETIMEDOUT",n&&(r.info=n),a=!0,o(r)}),e),r.apply(null,i)}))}var Un=Math.ceil,Nn=Math.max;function zn(t,e,n,r){var i=b(n);jt(function(t,e,n,r){for(var i=-1,o=Nn(Un((e-t)/(n||1)),0),u=Array(o);o--;)u[r?o:++i]=t,t+=n;return u}(0,t,1),e,i,r)}var Fn=At(zn,1/0),qn=At(zn,1);function Gn(t,e,n,r){arguments.length<=3&&(r=n,n=e,e=X(t)?[]:{}),r=G(r||q);var i=b(n);Ot(t,(function(t,n,r){i(e,t,n,r)}),(function(t){r(t,e)}))}function Yn(t,e){var n,r=null;e=e||q,Ke(t,(function(t,e){b(t)((function(t,i){n=arguments.length>2?o(arguments,1):i,r=t,e(!t)}))}),(function(){e(r,n)}))}function Kn(t){return function(){return(t.unmemoized||t).apply(null,arguments)}}function Wn(t,e,n){n=Et(n||q);var r=b(e);if(!t())return n(null);var i=function(e){if(e)return n(e);if(t())return r(i);var u=o(arguments,1);n.apply(null,[null].concat(u))};r(i)}function Hn(t,e,n){Wn((function(){return!t.apply(this,arguments)}),e,n)}var Vn=function(t,e){if(e=G(e||q),!X(t))return e(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return e();var n=0;function r(e){var r=b(t[n++]);e.push(Et(i)),r.apply(null,e)}function i(i){if(i||n===t.length)return e.apply(null,arguments);r(o(arguments,1))}r([])},$n={apply:u,applyEach:Dt,applyEachSeries:Bt,asyncify:d,auto:Yt,autoInject:ye,cargo:we,compose:xe,concat:ke,concatLimit:Ae,concatSeries:Re,constant:Oe,detect:De,detectLimit:Ie,detectSeries:je,dir:Be,doDuring:Ue,doUntil:ze,doWhilst:Ne,during:Fe,each:Ge,eachLimit:Ye,eachOf:Ot,eachOfLimit:Tt,eachOfSeries:_e,eachSeries:Ke,ensureAsync:We,every:Ve,everyLimit:$e,everySeries:Qe,filter:en,filterLimit:nn,filterSeries:rn,forever:on,groupBy:an,groupByLimit:un,groupBySeries:sn,log:cn,map:Mt,mapLimit:jt,mapSeries:Lt,mapValues:ln,mapValuesLimit:fn,mapValuesSeries:pn,memoize:dn,nextTick:gn,parallel:vn,parallelLimit:mn,priorityQueue:wn,queue:bn,race:_n,reduce:Se,reduceRight:Sn,reflect:En,reflectAll:xn,reject:An,rejectLimit:kn,rejectSeries:Rn,retry:Pn,retryable:Cn,seq:Ee,series:Mn,setImmediate:h,some:Dn,someLimit:In,someSeries:jn,sortBy:Ln,timeout:Bn,times:Fn,timesLimit:zn,timesSeries:qn,transform:Gn,tryEach:Yn,unmemoize:Kn,until:Hn,waterfall:Vn,whilst:Wn,all:Ve,allLimit:$e,allSeries:Qe,any:Dn,anyLimit:In,anySeries:jn,find:De,findLimit:Ie,findSeries:je,forEach:Ge,forEachSeries:Ke,forEachLimit:Ye,forEachOf:Ot,forEachOfSeries:_e,forEachOfLimit:Tt,inject:Se,foldl:Se,foldr:Sn,select:en,selectLimit:nn,selectSeries:rn,wrapSync:d};e.default=$n,e.apply=u,e.applyEach=Dt,e.applyEachSeries=Bt,e.asyncify=d,e.auto=Yt,e.autoInject=ye,e.cargo=we,e.compose=xe,e.concat=ke,e.concatLimit=Ae,e.concatSeries=Re,e.constant=Oe,e.detect=De,e.detectLimit=Ie,e.detectSeries=je,e.dir=Be,e.doDuring=Ue,e.doUntil=ze,e.doWhilst=Ne,e.during=Fe,e.each=Ge,e.eachLimit=Ye,e.eachOf=Ot,e.eachOfLimit=Tt,e.eachOfSeries=_e,e.eachSeries=Ke,e.ensureAsync=We,e.every=Ve,e.everyLimit=$e,e.everySeries=Qe,e.filter=en,e.filterLimit=nn,e.filterSeries=rn,e.forever=on,e.groupBy=an,e.groupByLimit=un,e.groupBySeries=sn,e.log=cn,e.map=Mt,e.mapLimit=jt,e.mapSeries=Lt,e.mapValues=ln,e.mapValuesLimit=fn,e.mapValuesSeries=pn,e.memoize=dn,e.nextTick=gn,e.parallel=vn,e.parallelLimit=mn,e.priorityQueue=wn,e.queue=bn,e.race=_n,e.reduce=Se,e.reduceRight=Sn,e.reflect=En,e.reflectAll=xn,e.reject=An,e.rejectLimit=kn,e.rejectSeries=Rn,e.retry=Pn,e.retryable=Cn,e.seq=Ee,e.series=Mn,e.setImmediate=h,e.some=Dn,e.someLimit=In,e.someSeries=jn,e.sortBy=Ln,e.timeout=Bn,e.times=Fn,e.timesLimit=zn,e.timesSeries=qn,e.transform=Gn,e.tryEach=Yn,e.unmemoize=Kn,e.until=Hn,e.waterfall=Vn,e.whilst=Wn,e.all=Ve,e.allLimit=$e,e.allSeries=Qe,e.any=Dn,e.anyLimit=In,e.anySeries=jn,e.find=De,e.findLimit=Ie,e.findSeries=je,e.forEach=Ge,e.forEachSeries=Ke,e.forEachLimit=Ye,e.forEachOf=Ot,e.forEachOfSeries=_e,e.forEachOfLimit=Tt,e.inject=Se,e.foldl=Se,e.foldr=Sn,e.select=en,e.selectLimit=nn,e.selectSeries=rn,e.wrapSync=d,Object.defineProperty(e,"__esModule",{value:!0})})(e)}).call(this,n(7).setImmediate,n(1),n(2),n(37)(t))},function(t,e,n){(function(e){var r=n(21),i=n(22),o={_parseHex:function(t){try{var n;return n="string"==typeof t?r.readFileSync(t,{encoding:"utf8"}):e.from(t),i.parse(n).data}catch(t){return t}},_hexStringToByte:function(t){return e.from([parseInt(t,16)])}};t.exports=o}).call(this,n(0).Buffer)},function(t,e,n){var r=n(0).Buffer;t.exports=function(t,e){if(r.isBuffer(t)&&r.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var n=0;n-1?r:o.nextTick;m.WritableState=v;var c=n(8);c.inherits=n(3);var f={deprecate:n(67)},l=n(26),p=n(11).Buffer,h=i.Uint8Array||function(){};var d,g=n(27);function y(){}function v(t,e){a=a||n(4),t=t||{};var r=e instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?(o.nextTick(i,r),o.nextTick(x,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(i(r),t._writableState.errorEmitted=!0,t.emit("error",r),x(t,e))}(t,n,r,e,i);else{var u=S(n);u||n.corked||n.bufferProcessing||!n.bufferedRequest||_(t,n),r?s(w,t,n,u,i):w(t,n,u,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new u(this)}function m(t){if(a=a||n(4),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new v(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function b(t,e,n,r,i,o,u){e.writelen=r,e.writecb=u,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function w(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),x(t,e)}function _(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)i[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;i.allBuffers=s,b(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new u(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(b(t,e,!1,e.objectMode?1:c.length,c,f,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final((function(n){e.pendingcb--,n&&t.emit("error",n),e.prefinished=!0,t.emit("prefinish"),x(t,e)}))}function x(t,e){var n=S(e);return n&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}c.inherits(m,l),v.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(v.prototype,"buffer",{get:f.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof v)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,n){var r,i=this._writableState,u=!1,a=!i.objectMode&&(r=t,p.isBuffer(r)||r instanceof h);return a&&!p.isBuffer(t)&&(t=function(t){return p.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=y),i.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),o.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var i=!0,u=!1;return null===n?u=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||e.objectMode||(u=new TypeError("Invalid non-string/buffer chunk")),u&&(t.emit("error",u),o.nextTick(r,u),i=!1),i}(this,i,t,n))&&(i.pendingcb++,u=function(t,e,n,r,i,o){if(!n){var u=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=p.from(e,n));return e}(e,r,i);r!==u&&(n=!0,i="buffer",r=u)}var a=e.objectMode?1:r.length;e.length+=a;var s=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,x(t,e),n&&(e.finished?o.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=g.destroy,m.prototype._undestroy=g.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,n(1),n(7).setImmediate,n(2))},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){},function(t,e,n){(function(t){e.parse=function(e,n){e instanceof t&&(e=e.toString("ascii"));var r=new t(n||8192),i=0,o=0,u=null,a=null,s=0,c=0;for(;c+11<=e.length;){if(":"!=e.charAt(c++))throw new Error("Line "+(s+1)+" does not start with a colon (:).");s++;var f=parseInt(e.substr(c,2),16);c+=2;var l=parseInt(e.substr(c,4),16);c+=4;var p=parseInt(e.substr(c,2),16);c+=2;var h=e.substr(c,2*f),d=new t(h,"hex");c+=2*f;var g=parseInt(e.substr(c,2),16);c+=2;for(var y=f+(l>>8)+l+p&255,v=0;v=r.length){var b=new t(2*(m+f));r.copy(b,0,0,i),r=b}m>i&&r.fill(255,i,m),d.copy(r,m),i=Math.max(i,m+f);break;case 1:if(0!=f)throw new Error("Invalid EOF record on line "+s+".");return{data:r.slice(0,i),startSegmentAddress:u,startLinearAddress:a};case 2:if(2!=f||0!=l)throw new Error("Invalid extended segment address record on line "+s+".");o=parseInt(h,16)<<4;break;case 3:if(4!=f||0!=l)throw new Error("Invalid start segment address record on line "+s+".");u=parseInt(h,16);break;case 4:if(2!=f||0!=l)throw new Error("Invalid extended linear address record on line "+s+".");o=parseInt(h,16)<<16;break;case 5:if(4!=f||0!=l)throw new Error("Invalid start linear address record on line "+s+".");a=parseInt(h,16);break;default:throw new Error("Invalid record type ("+p+") on line "+s)}"\r"==e.charAt(c)&&c++,"\n"==e.charAt(c)&&c++}throw new Error("Unexpected end of input: missing or invalid EOF record.")}}).call(this,n(0).Buffer)},function(t,e){function n(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}n.keys=function(){return[]},n.resolve=n,t.exports=n,n.id=23},function(t,e){t.exports.MESSAGE_START=27,t.exports.TOKEN=14,t.exports.CMD_SIGN_ON=1,t.exports.CMD_SET_PARAMETER=2,t.exports.CMD_GET_PARAMETER=3,t.exports.CMD_SET_DEVICE_PARAMETERS=4,t.exports.CMD_OSCCAL=5,t.exports.CMD_LOAD_ADDRESS=6,t.exports.CMD_FIRMWARE_UPGRADE=7,t.exports.CMD_ENTER_PROGMODE_ISP=16,t.exports.CMD_LEAVE_PROGMODE_ISP=17,t.exports.CMD_CHIP_ERASE_ISP=18,t.exports.CMD_PROGRAM_FLASH_ISP=19,t.exports.CMD_READ_FLASH_ISP=20,t.exports.CMD_PROGRAM_EEPROM_ISP=21,t.exports.CMD_READ_EEPROM_ISP=22,t.exports.CMD_PROGRAM_FUSE_ISP=23,t.exports.CMD_READ_FUSE_ISP=24,t.exports.CMD_PROGRAM_LOCK_ISP=25,t.exports.CMD_READ_LOCK_ISP=26,t.exports.CMD_READ_SIGNATURE_ISP=27,t.exports.CMD_READ_OSCCAL_ISP=28,t.exports.CMD_SPI_MULTI=29,t.exports.CMD_ENTER_PROGMODE_PP=32,t.exports.CMD_LEAVE_PROGMODE_PP=33,t.exports.CMD_CHIP_ERASE_PP=34,t.exports.CMD_PROGRAM_FLASH_PP=35,t.exports.CMD_READ_FLASH_PP=36,t.exports.CMD_PROGRAM_EEPROM_PP=37,t.exports.CMD_READ_EEPROM_PP=38,t.exports.CMD_PROGRAM_FUSE_PP=39,t.exports.CMD_READ_FUSE_PP=40,t.exports.CMD_PROGRAM_LOCK_PP=41,t.exports.CMD_READ_LOCK_PP=42,t.exports.CMD_READ_SIGNATURE_PP=43,t.exports.CMD_READ_OSCCAL_PP=44,t.exports.CMD_SET_CONTROL_STACK=45,t.exports.CMD_ENTER_PROGMODE_HVSP=48,t.exports.CMD_LEAVE_PROGMODE_HVSP=49,t.exports.CMD_CHIP_ERASE_HVSP=50,t.exports.CMD_PROGRAM_FLASH_HVSP=51,t.exports.CMD_READ_FLASH_HVSP=52,t.exports.CMD_PROGRAM_EEPROM_HVSP=53,t.exports.CMD_READ_EEPROM_HVSP=54,t.exports.CMD_PROGRAM_FUSE_HVSP=55,t.exports.CMD_READ_FUSE_HVSP=56,t.exports.CMD_PROGRAM_LOCK_HVSP=57,t.exports.CMD_READ_LOCK_HVSP=58,t.exports.CMD_READ_SIGNATURE_HVSP=59,t.exports.CMD_READ_OSCCAL_HVSP=60,t.exports.STATUS_CMD_OK=0,t.exports.STATUS_CMD_TOUT=128,t.exports.STATUS_RDY_BSY_TOUT=129,t.exports.STATUS_SET_PARAM_MISSING=130,t.exports.STATUS_CMD_FAILED=192,t.exports.STATUS_CKSUM_ERROR=193,t.exports.STATUS_CMD_UNKNOWN=201,t.exports.STATUS_BUILD_NUMBER_LOW=128,t.exports.STATUS_BUILD_NUMBER_HIGH=129,t.exports.STATUS_HW_VER=144,t.exports.STATUS_SW_MAJOR=145,t.exports.STATUS_SW_MINOR=146,t.exports.STATUS_VTARGET=148,t.exports.STATUS_VADJUST=149,t.exports.STATUS_OSC_PSCALE=150,t.exports.STATUS_OSC_CMATCH=151,t.exports.STATUS_SCK_DURATION=152,t.exports.STATUS_TOPCARD_DETECT=154,t.exports.STATUS_STATUS=156,t.exports.STATUS_DATA=157,t.exports.STATUS_RESET_POLARITY=158,t.exports.STATUS_CONTROLLER_INIT=159,t.exports.ANSWER_CKSUM_ERROR=176},function(t,e,n){"use strict";(function(e,r){var i=n(10);t.exports=b;var o,u=n(20);b.ReadableState=m;n(6).EventEmitter;var a=function(t,e){return t.listeners(e).length},s=n(26),c=n(11).Buffer,f=e.Uint8Array||function(){};var l=n(8);l.inherits=n(3);var p=n(64),h=void 0;h=p&&p.debuglog?p.debuglog("stream"):function(){};var d,g=n(65),y=n(27);l.inherits(b,s);var v=["error","close","destroy","pause","resume"];function m(t,e){t=t||{};var r=e instanceof(o=o||n(4));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,u=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(u||0===u)?u:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(28).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function b(t){if(o=o||n(4),!(this instanceof b))return new b(t);this._readableState=new m(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function w(t,e,n,r,i){var o,u=t._readableState;null===e?(u.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,x(t)}(t,u)):(i||(o=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(u,e)),o?t.emit("error",o):u.objectMode||e&&e.length>0?("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?u.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,u,e,!0):u.ended?t.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!n?(e=u.decoder.write(e),u.objectMode||0!==e.length?_(t,u,e,!1):A(t,u)):_(t,u,e,!1))):r||(u.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=S?t=S:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(h("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(T,t):T(t))}function T(t){h("emit readable"),t.emit("readable"),P(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;to.length?o.length:t;if(u===o.length?i+=o:i+=o.slice(0,t),0===(t-=u)){u===o.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(u));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var o=r.data,u=t>o.length?o.length:t;if(o.copy(n,n.length-t,0,u),0===(t-=u)){u===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(u));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function I(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return h("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):x(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return h("need readable",i),(0===e.length||e.length-t0?C(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:b;function c(e,r){h("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,h("cleanup"),t.removeListener("close",v),t.removeListener("finish",m),t.removeListener("drain",l),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",b),n.removeListener("data",g),p=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){h("onend"),t.end()}o.endEmitted?i.nextTick(s):n.once("end",s),t.on("unpipe",c);var l=function(t){return function(){var e=t._readableState;h("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",l);var p=!1;var d=!1;function g(e){h("ondata"),d=!1,!1!==t.write(e)||d||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==I(o.pipes,t))&&!p&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){h("onerror",e),b(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",m),b()}function m(){h("onfinish"),t.removeListener("close",v),b()}function b(){h("unpipe"),n.unpipe(t)}return n.on("data",g),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?u(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",v),t.once("finish",m),t.emit("pipe",n),o.flowing||(h("pipe resume"),n.resume()),t},b.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function s(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function f(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function p(t){return t.toString(this.encoding)}function h(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(t.lastNeed=i-1),i;if(--r=0)return i>0&&(t.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,n){"use strict";t.exports=u;var r=n(4),i=n(8);function o(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length0?u-4:u;for(n=0;n>16&255,s[f++]=e>>8&255,s[f++]=255&e;2===a&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,s[f++]=255&e);1===a&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,s[f++]=e>>8&255,s[f++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],u=0,a=n-i;ua?a:u+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=u.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t,e,n){for(var i,o,u=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return u.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,i){var o,u,a=8*i-r-1,s=(1<>1,f=-7,l=n?i-1:0,p=n?-1:1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=p,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=r;f>0;u=256*u+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===s)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),o-=c}return(h?-1:1)*u*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var u,a,s,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=f):(u=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-u))<1&&(u--,s*=2),(e+=u+l>=1?p/s:p*Math.pow(2,1-l))*s>=2&&(u++,s/=2),u+l>=f?(a=0,u=f):u+l>=1?(a=(e*s-1)*Math.pow(2,i),u+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),u=0));i>=8;t[n+h]=255&a,h+=d,a/=256,i-=8);for(u=u<0;t[n+h]=255&u,h+=d,u/=256,c-=8);t[n+h-d]|=128*g}},function(t,e,n){var r=n(35),i=n(12),o=n(38),u=(n(13),function(t){this.options=t,this.debug=this.options.debug?console.log.bind(console):function(){},this.board=this.options.board});u.prototype._init=function(t){this._setUpSerial((function(e){return t(e)}))},u.prototype._setUpSerial=function(t){return this.serialPort=new r("",{baudRate:this.board.baud,autoOpen:!1}),t(null)},u.prototype._sniffPort=function(t){var e=this.board.productId.map((function(t){return parseInt(t,16)}));this._listPorts((function(n,r){var i=r.filter((function(t){return-1!==e.indexOf(parseInt(t._standardPid,16))}));return t(null,i)}))},u.prototype._setDTR=function(t,e,n){var r={rts:t,dtr:t};this.serialPort.set(r,(function(t){if(t)return n(t);setTimeout((function(){n(t)}),e)}))},u.prototype._pollForPort=function(t){var e=this,n=o((function(t){var n=!1;e._sniffPort((function(r,i){i.length&&(e.options.port=i[0].comName,n=!0),t(n)}))}));n.every(100).ask(15),n((function(n){if(!n)return t(new Error("could not reconnect after resetting board."));e.debug("found port on",e.options.port),e._setUpSerial((function(e){return t(e)}))}))},u.prototype._pollForOpen=function(t){var e=this,n=o((function(t){e.serialPort.open((function(e){t(!e)}))}));n.every(200).ask(10),n((function(n){var r;n||(r=new Error("could not open board on "+e.serialPort.path)),t(r)}))},u.prototype._cycleDTR=function(t){i.series([this._setDTR.bind(this,!0,250),this._setDTR.bind(this,!1,50)],(function(e){return t(e)}))},u.prototype._listPorts=function(t){var e=[];r.list((function(n,r){if(n)return t(n);for(var i=0;it(null,e)).catch(e=>t(e))}open(t){navigator.serial.requestPort(this.requestOptions).then(t=>(this.port=t,this.port.open({baudrate:this.baudrate||57600}))).then(()=>this.writer=this.port.writable.getWriter()).then(()=>this.reader=this.port.readable.getReader()).then(async()=>{for(this.emit("open"),t(null);this.port.readable;)try{for(;;){const{value:t,done:n}=await this.reader.read();if(n)break;this.emit("data",e.from(t))}}catch(t){console.log("ERROR while reading port:",t)}}).catch(e=>{t(e)})}close(t){if(this.port.close(),t)return t(null)}set(t,e){this.port.setSignals(t).then(()=>e(null)).catch(t=>e(t))}write(t,e){return this.writer.write(t),e(null)}read(t){this.reader.read().then(e=>t(null,e)).catch(e=>t(e))}flush(){this.port.flush()}}}).call(this,n(0).Buffer)},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,u,a,s=1,c={},f=!1,l=t.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(t);p=p&&p.setTimeout?p:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){o.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(t){var e=l.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(u="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(u)&&d(+e.data.slice(u.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),r=function(e){t.postMessage(u+e,"*")}),p.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=o?n&&(n=null,r(!!t)):(u&&(!0===u?e=i(e,c):e+=c*u),s=setTimeout(f,e))}return(e=function(t){if(s&&(clearTimeout(s),s=null,n&&n(!1),n=null,c=0),arguments.length){if(!r(t,"function"))throw new TypeError("done callback must be a function");n=t}s=setTimeout(f,a)}).ask=function(t){if(s)throw new SyntaxError("can not set ask limit during polling");if(!r(t,"number"))throw new TypeError("ask limit must be a number");return o=t,e},e.every=function(t){if(s)throw new SyntaxError("can not set timeout during polling");if(!r(t,"number"))throw new TypeError("timout must be a number");return a=t,e},e.incr=function(t){if(s)throw new SyntexError("can not set increment during polling");if(!arguments.length||r(t,"boolean"))u=!!t;else{if(!r(t,"number"))throw new TypeError("increment must be a boolean or number");u=t}return e},e}()}},function(t,e){t.exports=function(t,e){function n(e){return"object"==typeof t&&null!==t}function r(t){return t.name.toLowerCase()}switch(2===arguments.length&&void 0===e?e="undefined":Number.isNaN(e)&&(e="NaN"),e){case"boolean":case"function":case"string":return typeof t===e;case"number":return typeof t===e&&!isNaN(t);case Number:if(isNaN(t))return!1;case String:case Boolean:return typeof t===r(e);case Object:case"object":return n();case"array":return Array.isArray(t);case"regex":case"regexp":return t instanceof RegExp;case"date":return t instanceof Date;case"null":case null:return null===t;case"undefined":return void 0===t;case"NaN":return Number.isNaN(t);case"arguments":return!!n()&&("function"==typeof t.callee||/arguments/i.test(t.toString()));default:return"function"==typeof e?t instanceof e:t}}},function(t,e){t.exports=function(t,e){for(var n=0;n++>8&255,c={cmd:[i.Cmnd_STK_LOAD_ADDRESS,a,s],responseData:i.OK_RESPONSE,timeout:n};o(t,c,(function(t,e){u.log("loaded address",t,e),r(t,e)}))},u.prototype.loadPage=function(t,n,r,u){this.log("load page");var a=this,s=255&n.length,c=n.length>>8,f={cmd:e.concat([new e([i.Cmnd_STK_PROG_PAGE,c,s,70]),n,new e([i.Sync_CRC_EOP])]),responseData:i.OK_RESPONSE,timeout:r};o(t,f,(function(t,e){a.log("loaded page",t,e),u(t,e)}))},u.prototype.upload=function(t,e,n,i,o){this.log("program");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.loadPage(t,u,i,e)},function(t){c.log("programmed page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("page done"),o(t)}))}),(function(t){c.log("upload done"),o(t)}))},u.prototype.exitProgrammingMode=function(t,e,n){this.log("send leave programming mode");var r=this,u={cmd:[i.Cmnd_STK_LEAVE_PROGMODE],responseData:i.OK_RESPONSE,timeout:e};o(t,u,(function(t,e){r.log("sent leave programming mode",t,e),n(t,e)}))},u.prototype.verify=function(t,e,n,i,o){this.log("verify");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.verifyPage(t,u,n,i,e)},function(t){c.log("verified page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("verify done"),o(t)}))}),(function(t){c.log("verify done"),o(t)}))},u.prototype.verifyPage=function(t,n,r,u,a){this.log("verify page");var s=this;match=e.concat([new e([i.Resp_STK_INSYNC]),n,new e([i.Resp_STK_OK])]);var c=n.length>=r?r:n.length,f={cmd:[i.Cmnd_STK_READ_PAGE,c>>8&255,255&c,70],responseLength:match.length,timeout:u};o(t,f,(function(t,e){s.log("confirm page",t,e,e.toString("hex")),a(t,e)}))},u.prototype.bootload=function(t,e,n,i){var o={pagesizehigh:n.pagesizehigh<<8&255,pagesizelow:255&n.pagesizelow};r.series([this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.verifySignature.bind(this,t,n.signature,n.timeout),this.setOptions.bind(this,t,o,n.timeout),this.enterProgrammingMode.bind(this,t,n.timeout),this.upload.bind(this,t,e,n.pageSize,n.timeout),this.verify.bind(this,t,e,n.pageSize,n.timeout),this.exitProgrammingMode.bind(this,t,n.timeout)],(function(t){return i(t)}))},t.exports=u}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i; +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e){var r=n(14),i=n(46),o=n(15);t.exports=function(t,n,u){var a,s=n.timeout||0,c=(o.Resp_STK_INSYNC,o.Resp_STK_NOSYNC,null),f=0;n.responseData&&n.responseData.length>0&&(c=n.responseData),c&&(f=c.length),n.responseLength&&(f=n.responseLength);var l=n.cmd;l instanceof Array&&(l=new e(l.concat(o.Sync_CRC_EOP))),t.write(l,(function(e){if(e)return a=new Error("Sending "+l.toString("hex")+": "+e.message),u(a);i(t,s,f,(function(t,e){return t?(a=new Error("Sending "+l.toString("hex")+": "+t.message),u(a)):c&&!r(e,c)?(a=new Error(l+" response mismatch: "+e.toString("hex")+", "+c.toString("hex")),u(a)):void u(null,e)}))}))}}).call(this,n(0).Buffer)},function(t,e,n){(function(e){var r=[n(15).Resp_STK_INSYNC];t.exports=function(t,n,i,o){var u=new e(0),a=!1,s=null,c=function(t){for(var n=0;!a&&ni)return f(new Error("buffer overflow "+u.length+" > "+i));u.length==i&&f()},f=function(e){s&&clearTimeout(s),t.removeListener("data",c),o(e,u)};n&&n>0&&(s=setTimeout((function(){s=null,f(new Error("receiveData timeout after "+n+"ms"))}),n)),t.on("data",c)}}).call(this,n(0).Buffer)},function(t,e){var n={};t.exports=n;var r={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(r).forEach((function(t){var e=r[t],i=n[t]=[];i.open="["+e[0]+"m",i.close="["+e[1]+"m"}))},function(t,e,n){(function(e){var n=e.argv;t.exports=!(-1!==n.indexOf("--no-color")||-1!==n.indexOf("--color=false")||-1===n.indexOf("--color")&&-1===n.indexOf("--color=true")&&-1===n.indexOf("--color=always")&&(e.stdout&&!e.stdout.isTTY||"win32"!==e.platform&&!("COLORTERM"in e.env||"dumb"!==e.env.TERM&&/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(e.env.TERM))))}).call(this,n(1))},function(t,e){t.exports=function(t,e){var n="";t=(t=t||"Run the trap, drop the bass").split("");var r={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","۝","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return t.forEach((function(t){t=t.toLowerCase();var e=r[t]||[" "],i=Math.floor(Math.random()*e.length);n+=void 0!==r[t]?r[t][i]:t})),n}},function(t,e){t.exports=function(t,e){t=t||" he is here ";var n={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},r=[].concat(n.up,n.down,n.mid);function i(t){return Math.floor(Math.random()*t)}function o(t){var e=!1;return r.filter((function(n){e=n===t})),e}return function(t,e){var r,u,a="";for(u in(e=e||{}).up=void 0===e.up||e.up,e.mid=void 0===e.mid||e.mid,e.down=void 0===e.down||e.down,e.size=void 0!==e.size?e.size:"maxi",t=t.split(""))if(!o(u)){switch(a+=t[u],r={up:0,down:0,mid:0},e.size){case"mini":r.up=i(8),r.mid=i(2),r.down=i(8);break;case"maxi":r.up=i(16)+3,r.mid=i(4)+1,r.down=i(64)+3;break;default:r.up=i(8)+1,r.mid=i(6)/2,r.down=i(8)+1}var s=["up","mid","down"];for(var c in s)for(var f=s[c],l=0;l<=r[f];l++)e[f]&&(a+=n[f][i(n[f].length)])}return a}(t,e)}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){if(" "===t)return t;switch(e%3){case 0:return r.red(t);case 1:return r.white(t);case 2:return r.blue(t)}}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){return e%2==0?t:r.inverse(t)}},function(t,e,n){var r,i=n(5);t.exports=(r=["red","yellow","green","blue","magenta"],function(t,e,n){return" "===t?t:i[r[e++%r.length]](t)})},function(t,e,n){var r,i=n(5);t.exports=(r=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"],function(t,e,n){return" "===t?t:i[r[Math.round(Math.random()*(r.length-1))]](t)})},function(t,e,n){var r=n(5);t.exports=function(){var t=function(t,e){String.prototype.__defineGetter__(t,e)};function e(e){var n=["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","charAt","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","charCodeAt","indexOf","lastIndexof","length","localeCompare","match","replace","search","slice","split","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","trimLeft","trimRight"];Object.keys(e).forEach((function(i){-1!==n.indexOf(i)?console.log("warn: ".red+("String.prototype"+i).magenta+" is probably something you don't want to override. Ignoring style name"):"string"==typeof e[i]?(r[i]=r[e[i]],t(i,(function(){return r[e[i]](this)}))):t(i,(function(){for(var t=this,n=0;n=6){var r=n.message[5];i.writeUInt8(r,0)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,1,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,1)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,2,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,2)}t(e)}))}],(function(e){t(e,i)}))},d.prototype.enterProgrammingMode=function(t,n){var r=this,i=Array.prototype.slice.call(arguments);"function"!=typeof(n=i.pop())&&(n=null),(t="function"!=typeof t&&t||{}).timeout=t.timeout||a,t.stabDelay=t.stabDelay||s,t.cmdexeDelay=t.cmdexeDelay||c,t.synchLoops=t.synchLoops||f,t.byteDelay=t.byteDelay||l,t.pollValue=t.pollValue||p,t.pollIndex=t.pollIndex||h;var o=172,u=83,d=0,g=0,y=new e([16,t.timeout,t.stabDelay,t.cmdexeDelay,t.synchLoops,t.byteDelay,t.pollValue,t.pollIndex,o,u,d,g]);r.parser.send(y,(function(t,e){n(t)}))},d.prototype.loadAddress=function(t,n){msb=t>>24&255|128,xsb=t>>16&255,ysb=t>>8&255,lsb=255&t;var r=new e([6,msb,xsb,ysb,lsb]);this.parser.send(r,(function(t,e){n(t)}))},d.prototype.loadPage=function(t,n){var r=t.length>>8,i=255&t.length,o=new e([19,r,i,193,10,64,76,32,0,0]);o=e.concat([o,t]),this.parser.send(o,(function(t,e){n(t)}))},d.prototype.upload=function(t,e,n){var i,o,u=0,a=this;r.whilst((function(){return u>1,t()},function(t){a.loadAddress(o,t)},function(n){i=t.slice(u,t.length>e?u+e:t.length-1),n()},function(t){a.loadPage(i,t)},function(t){u+=i.length,setTimeout(t,4)}],(function(t){n(t)}))}),(function(t){n(t)}))},d.prototype.exitProgrammingMode=function(t){var n=new e([17,1,1]);this.parser.send(n,(function(e,n){t(e)}))},d.prototype.verify=function(t,e){e()},d.prototype.bootload=function(t,e,n){n()},t.exports=d}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i; +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e,r){var i=n(24),o=n(6).EventEmitter;t.exports=function(t){var n,u,a=(n=new o,u={constants:i,port:t,boundOpen:!1,closed:!1,_inc:-1,_queue:[],_current:!1,states:["Start","GetSequenceNumber","GetMessageSize1","GetMessageSize2","GetToken","GetData","GetChecksum","Done"],state:0,pkt:!1,send:function(t,n){if(this.closed)return e((function(){var t=new Error("this parser is closed.");t.code="E_CLOSED",n(t)}));r.isBuffer(t)||(t=new r(t));var o=this._commandTimeout(t[0]),u=new r([0,0]);u.writeUInt16BE(t.length,0);var a=r.concat([new r([i.MESSAGE_START,this._seq(),u[0],u[1],i.TOKEN]),t]),s=this.checksum(a);this._queue.push({buf:r.concat([a,new r([s])]),seq:this._inc,cb:n,timeout:o}),this._send()},checksum:function(t){for(var e=0,n=0;n255&&(this._inc=0),this._inc},_commandTimeout:function(t){if(timeout=1e3,t===i.CMD_SIGN_ON)timeout=200;else for(var e=Object.keys(i),n=0;n-1||e[n].indexOf("PROGRAM_FLASH")>-1||e[n].indexOf("EEPROM")>-1)&&(timeout=5e3);break}return timeout},_send:function(){if(this.closed)return!1;if(!this._current&&this._queue.length)if("function"==typeof t.isOpen?t.isOpen():t.isOpen){var e=this._queue.shift(),n=this._current={timeout:!1,seq:e.seq,cb:e.cb};this._current,this.state=0,r=this,this.port.write(e.buf),this.port.drain((function(){if(n!==r._current)return r.emit("log","current was no longer the current message after drain callback");n.timeout=setTimeout((function(){var t=new Error("stk500 timeout. "+e.timeout+"ms");t.code="E_TIMEOUT",r._resolveCurrent(t)}),e.timeout)})),this.emit("rawinput",e.buf)}else{var r=this;this.boundOpen||t.once("open",(function(){r._send()}))}},_handle:function(t){var e=this._current;if(this.emit("raw",t),!e)return this.emit("log","notice","dropping data","data");for(var n=0;n ");for(var n=0;n126)&&(r="."),e.stdout.write(r+" ["+t.readUInt8(n).toString(16)+"] ")}e.stdout.write("\n")})),this.c=function(t,e,n){return r.cmds.push({value:t,callback:function(t){e&&e(t)},expectedResponseLength:n}),this},this.flashChunkSize=0,this.bytes=[],this.cmds=[]},o.Flasher.prototype={run:function(t){var n=this;e.nextTick((function(){if(!n.running){var i=n.cmds.shift();if(i){running=!0,n.options.debug&&e.stdout.write("Send: "+i.value);var o=new r(0),u=function(a){o=r.concat([o,a]),(void 0===i.expectedResponseLength||i.expectedResponseLength<=o.length)&&(n.sp.removeListener("data",u),n.running=!1,i.callback(o),e.nextTick((function(){n.cmds.length>0?n.run(t):t&&t()})))};n.sp.on("data",u),n.sp.write(i.value)}}}))},prepare:function(t){var e=this;this.c("S",(function(n){n.toString()!==e.signature&&t(new Error("Invalid device signature; expecting: "+e.signature+" received: "+n.toString()))})).c("V").c("v").c("p").c("a").c("b",(function(n){"Y"!=(n.toString()||"X")[0]&&t(new Error("Buffered memory access not supported.")),e.flashChunkSize=n.readUInt16BE(1)})).c("t").c("TD").c("P").c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c([u("A"),3,252]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]),this.run((function(){t(null,e)}))},erase:function(t){this.c("e",(function(){t&&t()})),this.run()},program:function(t,e){var n,r=this,o=[];this.totalBytes=0,this.c([u("A"),0,0],(function(){n=i.parse(t),r.totalBytes=n.data.length,Array.prototype.push.apply(o,n.data),r.allBytes=o,r.options.debug&&console.log("programming",o.length,"bytes"),r.chunksSent=[];for(var e=0;e>8&255,255&a.length,u("F")].concat(a))}})),this.run((function(){e&&e()}))},verify:function(t){var n=this;this.c([u("A"),0,0],(function(){var r=0,i=function(o){var a=null;if(r++,n.allBytes.length){var s=o.length;if(n.allBytes.splice(0,s).forEach((function(t,e){t!==o.readUInt8(e)&&(a=new Error("Firmware on the device does not match local data"))})),a)return t(a);e.nextTick((function(){var t=n.flashChunkSize;n.options.debug&&console.log(n.totalBytes-r*n.flashChunkSize),n.totalBytes-r*n.flashChunkSize>8&255,255&t,u("F")],i,t),n.run()}))}else t&&t()};n.options.debug&&console.log("\n\nVerifying flash.."),n.c([u("g"),n.flashChunkSize>>8&255,255&n.flashChunkSize,u("F")],i,n.flashChunkSize),n.run()})),n.run()},fuseCheck:fuseCheck=function(t){this.options.debug&&console.log("checking fuses"),this.c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c("L").c("E"),this.run((function(){t()}))}},o.init=function(t,e,n){"function"!=typeof e||n||(n=e,e={}),new o.Flasher(t,e).prepare(n)}}).call(this,n(1),n(0).Buffer)},function(t,e,n){t.exports=i;var r=n(6).EventEmitter;function i(){r.call(this)}n(3)(i,r),i.Readable=n(18),i.Writable=n(69),i.Duplex=n(70),i.Transform=n(71),i.PassThrough=n(72),i.Stream=i,i.prototype.pipe=function(t,e){var n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(n.on("end",a),n.on("close",s));var u=!1;function a(){u||(u=!0,t.end())}function s(){u||(u=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===r.listenerCount(this,"error"))throw t}function f(){n.removeListener("data",i),t.removeListener("drain",o),n.removeListener("end",a),n.removeListener("close",s),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",f),n.removeListener("close",f),t.removeListener("close",f)}return n.on("error",c),t.on("error",c),n.on("end",f),n.on("close",f),t.on("close",f),t.emit("pipe",n),t}},function(t,e){},function(t,e,n){"use strict";var r=n(11).Buffer,i=n(66);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var e,n,i,o=r.allocUnsafe(t>>>0),u=this.head,a=0;u;)e=u.data,n=o,i=a,e.copy(n,i),a+=u.data.length,u=u.next;return o},t}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(2))},function(t,e,n){"use strict";t.exports=o;var r=n(29),i=n(8);function o(t){if(!(this instanceof o))return new o(t);r.call(this,t)}i.inherits=n(3),i.inherits(o,r),o.prototype._transform=function(t,e,n){n(null,t)}},function(t,e,n){t.exports=n(19)},function(t,e,n){t.exports=n(4)},function(t,e,n){t.exports=n(18).Transform},function(t,e,n){t.exports=n(18).PassThrough},function(t,e){},function(t,e){t.exports=function(t,e,n){var r=function(r){if(r=r||{},this.options={debug:r.debug||!1,board:r.board||"uno",port:r.port||"",manualReset:r.manualReset||!1},!0===this.options.debug?this.debug=console.log.bind(console):"function"==typeof this.options.debug?this.debug=this.options.debug:this.debug=function(){},"string"==typeof this.options.board?this.options.board=t[this.options.board]:"object"==typeof this.options.board&&(this.options.board=this.options.board),this.options.board&&!this.options.board.manualReset&&(this.options.board.manualReset=this.options.manualReset),this.connection=new e(this.options),this.options.board){var i=n[this.options.board.protocol]||function(){};this.protocol=new i({board:this.options.board,connection:this.connection,debug:this.debug})}};return r.prototype._validateBoard=function(t){if("object"!=typeof this.options.board)return t(new Error('"'+this.options.board+'" is not a supported board type.'));if(this.protocol.chip)return this.options.port||"pro-mini"!==this.options.board.name?t(null):t(new Error("using a pro-mini, please specify the port in your options."));var e="not a supported programming protocol: "+this.options.board.protocol;return t(new Error(e))},r.prototype.flash=function(t,e){var n=this;n._validateBoard((function(r){if(r)return e(r);n.connection._init((function(r){if(r)return e(r);n.protocol._upload(t,e)}))}))},r.prototype.listPorts=r.listPorts=r.prototype.list=r.list=function(t){return e.prototype._listPorts(t)},r.listKnownBoards=function(){return Object.keys(t).filter((function(e){var n=t[e].aliases;return!n||!~n.indexOf(e)}))},r}}])})); \ No newline at end of file diff --git a/dist/avrgirl-arduino.min.js b/dist/avrgirl-arduino.min.js new file mode 100644 index 0000000..6807eaa --- /dev/null +++ b/dist/avrgirl-arduino.min.js @@ -0,0 +1,2 @@ +/*! For license information please see avrgirl-arduino.min.js.LICENSE */ +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=30)}([function(t,e,n){"use strict";(function(t){var r=n(32),i=n(33),o=n(20);function u(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(u()=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(r)return F(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return O(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){var o,u=1,a=t.length,s=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,a/=2,s/=2,n/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(i){var f=-1;for(o=n;oa&&(n=a-s),o=n;o>=0;o--){for(var l=!0,p=0;pi&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var u=0;u>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function T(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&c)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=t[i+1],u=t[i+2],a=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&a)&&(s=(15&c)<<18|(63&o)<<12|(63&u)<<6|63&a)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=l}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0),a=Math.min(o,u),c=this.slice(r,i),f=t.slice(e,n),l=0;li)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":return _(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function R(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function I(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function j(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function L(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(t,e,n,r,o){return o||L(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return o||L(t,0,n,8),i.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=this[t],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=0,u=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=n-1,u=1,a=0;for(this[e+o]=255&t;--o>=0&&(u*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/u>>0)-a&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function q(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(2))},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,c=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?c=s.concat(c):l=-1,c.length&&h())}function h(){if(!f){var t=a(p);f=!0;for(var e=c.length;e;){for(s=c,c=[];++l1)for(var n=1;n1)for(var o=1;o0&&u.length>i&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=u.length,a=s,console&&console.warn&&console.warn(a)}return t}function l(){for(var t=[],e=0;e0&&(u=e[0]),u instanceof Error)throw u;var a=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw a.context=u,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)o(s,this,e);else{var c=s.length,f=g(s,c);for(n=0;n=0;o--)if(n[o]===e||n[o].listener===e){u=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},a.prototype.listeners=function(t){return h(this,t,!0)},a.prototype.rawListeners=function(t){return h(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},a.prototype.listenerCount=d,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(36),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(2))},function(t,e,n){(function(t){function n(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===n(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===n(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===n(t)},e.isError=function(t){return"[object Error]"===n(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,n(0).Buffer)},function(t,e,n){(function(t){var r=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,t,r.depth)}function s(t,e){var n=a.styles[e];return n?"["+a.colors[n][0]+"m"+t+"["+a.colors[n][1]+"m":t}function c(t,e){return t}function f(t,n,r){if(t.customInspect&&n&&E(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=f(t,i,r)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(y(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,n);if(o)return o;var u=Object.keys(n),a=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(n)),S(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return l(n);if(0===u.length){if(E(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(b(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(_(n))return t.stylize(Date.prototype.toString.call(n),"date");if(S(n))return l(n)}var c,w="",x=!1,T=["{","}"];(h(n)&&(x=!0,T=["[","]"]),E(n))&&(w=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(w=" "+RegExp.prototype.toString.call(n)),_(n)&&(w=" "+Date.prototype.toUTCString.call(n)),S(n)&&(w=" "+l(n)),0!==u.length||x&&0!=n.length?r<0?b(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),c=x?function(t,e,n,r,i){for(var o=[],u=0,a=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(c,w,T)):T[0]+w+T[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,n,r,i,o){var u,a,s;if((s=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(a=t.stylize("[Setter]","special")),R(r,i)||(u="["+i+"]"),a||(t.seen.indexOf(s.value)<0?(a=g(n)?f(t,s.value,null):f(t,s.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),m(u)){if(o&&i.match(/^\d+$/))return a;(u=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+a}function h(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return void 0===t}function b(t){return w(t)&&"[object RegExp]"===x(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===x(t)}function S(t){return w(t)&&("[object Error]"===x(t)||t instanceof Error)}function E(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(m(o)&&(o=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!u[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=t.pid;u[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else u[n]=function(){};return u[n]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=d,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=y,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=b,e.isObject=w,e.isDate=_,e.isError=S,e.isFunction=E,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(56);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",k(),e.format.apply(e,arguments))},e.inherits=n(3),e._extend=function(t,e){if(!e||!w(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function P(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(O&&t[O]){var e;if("function"!=typeof(e=t[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,O,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),i=[],o=0;o-1&&t%1==0&&t<=U}function z(t){return null!=t&&N(t.length)&&!function(t){if(!s(t))return!1;var e=D(t);return e==j||e==L||e==I||e==B}(t)}var F={};function q(){}function G(t){return function(){if(null!==t){var e=t;t=null,e.apply(this,arguments)}}}var Y="function"==typeof Symbol&&Symbol.iterator,K=function(t){return Y&&t[Y]&&t[Y]()};function W(t){return null!=t&&"object"==typeof t}var H="[object Arguments]";function V(t){return W(t)&&D(t)==H}var $=Object.prototype,Q=$.hasOwnProperty,J=$.propertyIsEnumerable,Z=V(function(){return arguments}())?V:function(t){return W(t)&&Q.call(t,"callee")&&!J.call(t,"callee")},X=Array.isArray,tt="object"==typeof e&&e&&!e.nodeType&&e,et=tt&&"object"==typeof i&&i&&!i.nodeType&&i,nt=et&&et.exports===tt?E.Buffer:void 0,rt=(nt?nt.isBuffer:void 0)||function(){return!1},it=9007199254740991,ot=/^(?:0|[1-9]\d*)$/;function ut(t,e){return!!(e=null==e?it:e)&&("number"==typeof t||ot.test(t))&&t>-1&&t%1==0&&t2&&(r=o(arguments,1)),e){var c={};Ft(i,(function(t,e){c[e]=t})),c[t]=r,a=!0,s=Object.create(null),n(e,c)}else i[t]=r,d(t)}));u++;var c=b(e[e.length-1]);e.length>1?c(i,r):c(r)}}(t,e)}))}function h(){if(0===c.length&&0===u)return n(null,i);for(;c.length&&u=0&&n.push(r)})),n}Ft(t,(function(e,n){if(!X(e))return p(n,[e]),void f.push(n);var r=e.slice(0,e.length-1),i=r.length;if(0===i)return p(n,e),void f.push(n);l[n]=i,Ut(r,(function(o){if(!t[o])throw new Error("async.auto task `"+n+"` has a non-existent dependency `"+o+"` in "+r.join(", "));var u,a,c;a=function(){0==--i&&p(n,e)},(c=s[u=o])||(c=s[u]=[]),c.push(a)}))})),function(){for(var t,e=0;f.length;)t=f.pop(),e++,Ut(g(t),(function(t){0==--l[t]&&f.push(t)}));if(e!==r)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),h()};function Kt(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n=r?t:function(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=Array(i);++r-1;);return n}(i,o),function(t,e){for(var n=t.length;n--&&Gt(e,t[n],0)>-1;);return n}(i,o)+1).join("")}var pe=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,he=/,/,de=/(=.+)?(\s*)$/,ge=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function ye(t,e){var n={};Ft(t,(function(t,e){var r,i=m(t),o=!i&&1===t.length||i&&0===t.length;if(X(t))r=t.slice(0,-1),t=t[t.length-1],n[e]=r.concat(r.length>0?u:t);else if(o)n[e]=t;else{if(r=function(t){return t=(t=(t=(t=t.toString().replace(ge,"")).match(pe)[2].replace(" ",""))?t.split(he):[]).map((function(t){return le(t.replace(de,""))}))}(t),0===t.length&&!i&&0===r.length)throw new Error("autoInject task functions require explicit parameters.");i||r.pop(),n[e]=r.concat(u)}function u(e,n){var i=Kt(r,(function(t){return e[t]}));i.push(n),b(t).apply(null,i)}})),Yt(n,e)}function ve(){this.head=this.tail=null,this.length=0}function me(t,e){t.length=1,t.head=t.tail=e}function be(t,e,n){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var r=b(t),i=0,o=[],u=!1;function a(t,e,n){if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");if(f.started=!0,X(t)||(t=[t]),0===t.length&&f.idle())return h((function(){f.drain()}));for(var r=0,i=t.length;r0&&o.splice(a,1),u.callback.apply(u,arguments),null!=e&&f.error(e,u.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new ve,concurrency:e,payload:n,saturated:q,unsaturated:q,buffer:e/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(t,e){a(t,!1,e)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(t,e){a(t,!0,e)},remove:function(t){f._tasks.remove(t)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(i=o(arguments,1)),r[e]=i,n(t)}))}),(function(t){n(t,r)}))}function vn(t,e){yn(Ot,t,e)}function mn(t,e,n){yn(xt(e),t,n)}var bn=function(t,e){var n=b(t);return be((function(t,e){n(t[0],e)}),e,1)},wn=function(t,e){var n=bn(t,e);return n.push=function(t,e,r){if(null==r&&(r=q),"function"!=typeof r)throw new Error("task callback must be a function");if(n.started=!0,X(t)||(t=[t]),0===t.length)return h((function(){n.drain()}));e=e||0;for(var i=n._tasks.head;i&&e>=i.priority;)i=i.next;for(var o=0,u=t.length;or?1:0}Mt(t,(function(t,e){r(t,(function(n,r){if(n)return e(n);e(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,Kt(e.sort(i),Je("value")))}))}function Bn(t,e,n){var r=b(t);return a((function(i,o){var u,a=!1;i.push((function(){a||(o.apply(null,arguments),clearTimeout(u))})),u=setTimeout((function(){var e=t.name||"anonymous",r=new Error('Callback function "'+e+'" timed out.');r.code="ETIMEDOUT",n&&(r.info=n),a=!0,o(r)}),e),r.apply(null,i)}))}var Un=Math.ceil,Nn=Math.max;function zn(t,e,n,r){var i=b(n);jt(function(t,e,n,r){for(var i=-1,o=Nn(Un((e-t)/(n||1)),0),u=Array(o);o--;)u[r?o:++i]=t,t+=n;return u}(0,t,1),e,i,r)}var Fn=At(zn,1/0),qn=At(zn,1);function Gn(t,e,n,r){arguments.length<=3&&(r=n,n=e,e=X(t)?[]:{}),r=G(r||q);var i=b(n);Ot(t,(function(t,n,r){i(e,t,n,r)}),(function(t){r(t,e)}))}function Yn(t,e){var n,r=null;e=e||q,Ke(t,(function(t,e){b(t)((function(t,i){n=arguments.length>2?o(arguments,1):i,r=t,e(!t)}))}),(function(){e(r,n)}))}function Kn(t){return function(){return(t.unmemoized||t).apply(null,arguments)}}function Wn(t,e,n){n=Et(n||q);var r=b(e);if(!t())return n(null);var i=function(e){if(e)return n(e);if(t())return r(i);var u=o(arguments,1);n.apply(null,[null].concat(u))};r(i)}function Hn(t,e,n){Wn((function(){return!t.apply(this,arguments)}),e,n)}var Vn=function(t,e){if(e=G(e||q),!X(t))return e(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return e();var n=0;function r(e){var r=b(t[n++]);e.push(Et(i)),r.apply(null,e)}function i(i){if(i||n===t.length)return e.apply(null,arguments);r(o(arguments,1))}r([])},$n={apply:u,applyEach:Dt,applyEachSeries:Bt,asyncify:d,auto:Yt,autoInject:ye,cargo:we,compose:xe,concat:ke,concatLimit:Ae,concatSeries:Re,constant:Oe,detect:De,detectLimit:Ie,detectSeries:je,dir:Be,doDuring:Ue,doUntil:ze,doWhilst:Ne,during:Fe,each:Ge,eachLimit:Ye,eachOf:Ot,eachOfLimit:Tt,eachOfSeries:_e,eachSeries:Ke,ensureAsync:We,every:Ve,everyLimit:$e,everySeries:Qe,filter:en,filterLimit:nn,filterSeries:rn,forever:on,groupBy:an,groupByLimit:un,groupBySeries:sn,log:cn,map:Mt,mapLimit:jt,mapSeries:Lt,mapValues:ln,mapValuesLimit:fn,mapValuesSeries:pn,memoize:dn,nextTick:gn,parallel:vn,parallelLimit:mn,priorityQueue:wn,queue:bn,race:_n,reduce:Se,reduceRight:Sn,reflect:En,reflectAll:xn,reject:An,rejectLimit:kn,rejectSeries:Rn,retry:Pn,retryable:Cn,seq:Ee,series:Mn,setImmediate:h,some:Dn,someLimit:In,someSeries:jn,sortBy:Ln,timeout:Bn,times:Fn,timesLimit:zn,timesSeries:qn,transform:Gn,tryEach:Yn,unmemoize:Kn,until:Hn,waterfall:Vn,whilst:Wn,all:Ve,allLimit:$e,allSeries:Qe,any:Dn,anyLimit:In,anySeries:jn,find:De,findLimit:Ie,findSeries:je,forEach:Ge,forEachSeries:Ke,forEachLimit:Ye,forEachOf:Ot,forEachOfSeries:_e,forEachOfLimit:Tt,inject:Se,foldl:Se,foldr:Sn,select:en,selectLimit:nn,selectSeries:rn,wrapSync:d};e.default=$n,e.apply=u,e.applyEach=Dt,e.applyEachSeries=Bt,e.asyncify=d,e.auto=Yt,e.autoInject=ye,e.cargo=we,e.compose=xe,e.concat=ke,e.concatLimit=Ae,e.concatSeries=Re,e.constant=Oe,e.detect=De,e.detectLimit=Ie,e.detectSeries=je,e.dir=Be,e.doDuring=Ue,e.doUntil=ze,e.doWhilst=Ne,e.during=Fe,e.each=Ge,e.eachLimit=Ye,e.eachOf=Ot,e.eachOfLimit=Tt,e.eachOfSeries=_e,e.eachSeries=Ke,e.ensureAsync=We,e.every=Ve,e.everyLimit=$e,e.everySeries=Qe,e.filter=en,e.filterLimit=nn,e.filterSeries=rn,e.forever=on,e.groupBy=an,e.groupByLimit=un,e.groupBySeries=sn,e.log=cn,e.map=Mt,e.mapLimit=jt,e.mapSeries=Lt,e.mapValues=ln,e.mapValuesLimit=fn,e.mapValuesSeries=pn,e.memoize=dn,e.nextTick=gn,e.parallel=vn,e.parallelLimit=mn,e.priorityQueue=wn,e.queue=bn,e.race=_n,e.reduce=Se,e.reduceRight=Sn,e.reflect=En,e.reflectAll=xn,e.reject=An,e.rejectLimit=kn,e.rejectSeries=Rn,e.retry=Pn,e.retryable=Cn,e.seq=Ee,e.series=Mn,e.setImmediate=h,e.some=Dn,e.someLimit=In,e.someSeries=jn,e.sortBy=Ln,e.timeout=Bn,e.times=Fn,e.timesLimit=zn,e.timesSeries=qn,e.transform=Gn,e.tryEach=Yn,e.unmemoize=Kn,e.until=Hn,e.waterfall=Vn,e.whilst=Wn,e.all=Ve,e.allLimit=$e,e.allSeries=Qe,e.any=Dn,e.anyLimit=In,e.anySeries=jn,e.find=De,e.findLimit=Ie,e.findSeries=je,e.forEach=Ge,e.forEachSeries=Ke,e.forEachLimit=Ye,e.forEachOf=Ot,e.forEachOfSeries=_e,e.forEachOfLimit=Tt,e.inject=Se,e.foldl=Se,e.foldr=Sn,e.select=en,e.selectLimit=nn,e.selectSeries=rn,e.wrapSync=d,Object.defineProperty(e,"__esModule",{value:!0})})(e)}).call(this,n(7).setImmediate,n(1),n(2),n(37)(t))},function(t,e,n){(function(e){var r=n(21),i=n(22),o={_parseHex:function(t){try{var n;return n="string"==typeof t?r.readFileSync(t,{encoding:"utf8"}):e.from(t),i.parse(n).data}catch(t){return t}},_hexStringToByte:function(t){return e.from([parseInt(t,16)])}};t.exports=o}).call(this,n(0).Buffer)},function(t,e,n){var r=n(0).Buffer;t.exports=function(t,e){if(r.isBuffer(t)&&r.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var n=0;n-1?r:o.nextTick;m.WritableState=v;var c=n(8);c.inherits=n(3);var f={deprecate:n(67)},l=n(26),p=n(11).Buffer,h=i.Uint8Array||function(){};var d,g=n(27);function y(){}function v(t,e){a=a||n(4),t=t||{};var r=e instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?(o.nextTick(i,r),o.nextTick(x,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(i(r),t._writableState.errorEmitted=!0,t.emit("error",r),x(t,e))}(t,n,r,e,i);else{var u=S(n);u||n.corked||n.bufferProcessing||!n.bufferedRequest||_(t,n),r?s(w,t,n,u,i):w(t,n,u,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new u(this)}function m(t){if(a=a||n(4),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new v(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function b(t,e,n,r,i,o,u){e.writelen=r,e.writecb=u,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function w(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),x(t,e)}function _(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)i[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;i.allBuffers=s,b(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new u(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(b(t,e,!1,e.objectMode?1:c.length,c,f,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final((function(n){e.pendingcb--,n&&t.emit("error",n),e.prefinished=!0,t.emit("prefinish"),x(t,e)}))}function x(t,e){var n=S(e);return n&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}c.inherits(m,l),v.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(v.prototype,"buffer",{get:f.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof v)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,n){var r,i=this._writableState,u=!1,a=!i.objectMode&&(r=t,p.isBuffer(r)||r instanceof h);return a&&!p.isBuffer(t)&&(t=function(t){return p.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=y),i.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),o.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var i=!0,u=!1;return null===n?u=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||e.objectMode||(u=new TypeError("Invalid non-string/buffer chunk")),u&&(t.emit("error",u),o.nextTick(r,u),i=!1),i}(this,i,t,n))&&(i.pendingcb++,u=function(t,e,n,r,i,o){if(!n){var u=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=p.from(e,n));return e}(e,r,i);r!==u&&(n=!0,i="buffer",r=u)}var a=e.objectMode?1:r.length;e.length+=a;var s=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,x(t,e),n&&(e.finished?o.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=g.destroy,m.prototype._undestroy=g.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,n(1),n(7).setImmediate,n(2))},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){},function(t,e,n){(function(t){e.parse=function(e,n){e instanceof t&&(e=e.toString("ascii"));var r=new t(n||8192),i=0,o=0,u=null,a=null,s=0,c=0;for(;c+11<=e.length;){if(":"!=e.charAt(c++))throw new Error("Line "+(s+1)+" does not start with a colon (:).");s++;var f=parseInt(e.substr(c,2),16);c+=2;var l=parseInt(e.substr(c,4),16);c+=4;var p=parseInt(e.substr(c,2),16);c+=2;var h=e.substr(c,2*f),d=new t(h,"hex");c+=2*f;var g=parseInt(e.substr(c,2),16);c+=2;for(var y=f+(l>>8)+l+p&255,v=0;v=r.length){var b=new t(2*(m+f));r.copy(b,0,0,i),r=b}m>i&&r.fill(255,i,m),d.copy(r,m),i=Math.max(i,m+f);break;case 1:if(0!=f)throw new Error("Invalid EOF record on line "+s+".");return{data:r.slice(0,i),startSegmentAddress:u,startLinearAddress:a};case 2:if(2!=f||0!=l)throw new Error("Invalid extended segment address record on line "+s+".");o=parseInt(h,16)<<4;break;case 3:if(4!=f||0!=l)throw new Error("Invalid start segment address record on line "+s+".");u=parseInt(h,16);break;case 4:if(2!=f||0!=l)throw new Error("Invalid extended linear address record on line "+s+".");o=parseInt(h,16)<<16;break;case 5:if(4!=f||0!=l)throw new Error("Invalid start linear address record on line "+s+".");a=parseInt(h,16);break;default:throw new Error("Invalid record type ("+p+") on line "+s)}"\r"==e.charAt(c)&&c++,"\n"==e.charAt(c)&&c++}throw new Error("Unexpected end of input: missing or invalid EOF record.")}}).call(this,n(0).Buffer)},function(t,e){function n(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}n.keys=function(){return[]},n.resolve=n,t.exports=n,n.id=23},function(t,e){t.exports.MESSAGE_START=27,t.exports.TOKEN=14,t.exports.CMD_SIGN_ON=1,t.exports.CMD_SET_PARAMETER=2,t.exports.CMD_GET_PARAMETER=3,t.exports.CMD_SET_DEVICE_PARAMETERS=4,t.exports.CMD_OSCCAL=5,t.exports.CMD_LOAD_ADDRESS=6,t.exports.CMD_FIRMWARE_UPGRADE=7,t.exports.CMD_ENTER_PROGMODE_ISP=16,t.exports.CMD_LEAVE_PROGMODE_ISP=17,t.exports.CMD_CHIP_ERASE_ISP=18,t.exports.CMD_PROGRAM_FLASH_ISP=19,t.exports.CMD_READ_FLASH_ISP=20,t.exports.CMD_PROGRAM_EEPROM_ISP=21,t.exports.CMD_READ_EEPROM_ISP=22,t.exports.CMD_PROGRAM_FUSE_ISP=23,t.exports.CMD_READ_FUSE_ISP=24,t.exports.CMD_PROGRAM_LOCK_ISP=25,t.exports.CMD_READ_LOCK_ISP=26,t.exports.CMD_READ_SIGNATURE_ISP=27,t.exports.CMD_READ_OSCCAL_ISP=28,t.exports.CMD_SPI_MULTI=29,t.exports.CMD_ENTER_PROGMODE_PP=32,t.exports.CMD_LEAVE_PROGMODE_PP=33,t.exports.CMD_CHIP_ERASE_PP=34,t.exports.CMD_PROGRAM_FLASH_PP=35,t.exports.CMD_READ_FLASH_PP=36,t.exports.CMD_PROGRAM_EEPROM_PP=37,t.exports.CMD_READ_EEPROM_PP=38,t.exports.CMD_PROGRAM_FUSE_PP=39,t.exports.CMD_READ_FUSE_PP=40,t.exports.CMD_PROGRAM_LOCK_PP=41,t.exports.CMD_READ_LOCK_PP=42,t.exports.CMD_READ_SIGNATURE_PP=43,t.exports.CMD_READ_OSCCAL_PP=44,t.exports.CMD_SET_CONTROL_STACK=45,t.exports.CMD_ENTER_PROGMODE_HVSP=48,t.exports.CMD_LEAVE_PROGMODE_HVSP=49,t.exports.CMD_CHIP_ERASE_HVSP=50,t.exports.CMD_PROGRAM_FLASH_HVSP=51,t.exports.CMD_READ_FLASH_HVSP=52,t.exports.CMD_PROGRAM_EEPROM_HVSP=53,t.exports.CMD_READ_EEPROM_HVSP=54,t.exports.CMD_PROGRAM_FUSE_HVSP=55,t.exports.CMD_READ_FUSE_HVSP=56,t.exports.CMD_PROGRAM_LOCK_HVSP=57,t.exports.CMD_READ_LOCK_HVSP=58,t.exports.CMD_READ_SIGNATURE_HVSP=59,t.exports.CMD_READ_OSCCAL_HVSP=60,t.exports.STATUS_CMD_OK=0,t.exports.STATUS_CMD_TOUT=128,t.exports.STATUS_RDY_BSY_TOUT=129,t.exports.STATUS_SET_PARAM_MISSING=130,t.exports.STATUS_CMD_FAILED=192,t.exports.STATUS_CKSUM_ERROR=193,t.exports.STATUS_CMD_UNKNOWN=201,t.exports.STATUS_BUILD_NUMBER_LOW=128,t.exports.STATUS_BUILD_NUMBER_HIGH=129,t.exports.STATUS_HW_VER=144,t.exports.STATUS_SW_MAJOR=145,t.exports.STATUS_SW_MINOR=146,t.exports.STATUS_VTARGET=148,t.exports.STATUS_VADJUST=149,t.exports.STATUS_OSC_PSCALE=150,t.exports.STATUS_OSC_CMATCH=151,t.exports.STATUS_SCK_DURATION=152,t.exports.STATUS_TOPCARD_DETECT=154,t.exports.STATUS_STATUS=156,t.exports.STATUS_DATA=157,t.exports.STATUS_RESET_POLARITY=158,t.exports.STATUS_CONTROLLER_INIT=159,t.exports.ANSWER_CKSUM_ERROR=176},function(t,e,n){"use strict";(function(e,r){var i=n(10);t.exports=b;var o,u=n(20);b.ReadableState=m;n(6).EventEmitter;var a=function(t,e){return t.listeners(e).length},s=n(26),c=n(11).Buffer,f=e.Uint8Array||function(){};var l=n(8);l.inherits=n(3);var p=n(64),h=void 0;h=p&&p.debuglog?p.debuglog("stream"):function(){};var d,g=n(65),y=n(27);l.inherits(b,s);var v=["error","close","destroy","pause","resume"];function m(t,e){t=t||{};var r=e instanceof(o=o||n(4));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,u=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(u||0===u)?u:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(28).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function b(t){if(o=o||n(4),!(this instanceof b))return new b(t);this._readableState=new m(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function w(t,e,n,r,i){var o,u=t._readableState;null===e?(u.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,x(t)}(t,u)):(i||(o=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(u,e)),o?t.emit("error",o):u.objectMode||e&&e.length>0?("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?u.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,u,e,!0):u.ended?t.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!n?(e=u.decoder.write(e),u.objectMode||0!==e.length?_(t,u,e,!1):A(t,u)):_(t,u,e,!1))):r||(u.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=S?t=S:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(h("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(T,t):T(t))}function T(t){h("emit readable"),t.emit("readable"),P(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;to.length?o.length:t;if(u===o.length?i+=o:i+=o.slice(0,t),0===(t-=u)){u===o.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(u));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var o=r.data,u=t>o.length?o.length:t;if(o.copy(n,n.length-t,0,u),0===(t-=u)){u===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(u));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function I(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return h("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):x(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return h("need readable",i),(0===e.length||e.length-t0?C(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:b;function c(e,r){h("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,h("cleanup"),t.removeListener("close",v),t.removeListener("finish",m),t.removeListener("drain",l),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",b),n.removeListener("data",g),p=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){h("onend"),t.end()}o.endEmitted?i.nextTick(s):n.once("end",s),t.on("unpipe",c);var l=function(t){return function(){var e=t._readableState;h("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",l);var p=!1;var d=!1;function g(e){h("ondata"),d=!1,!1!==t.write(e)||d||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==I(o.pipes,t))&&!p&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){h("onerror",e),b(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",m),b()}function m(){h("onfinish"),t.removeListener("close",v),b()}function b(){h("unpipe"),n.unpipe(t)}return n.on("data",g),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?u(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",v),t.once("finish",m),t.emit("pipe",n),o.flowing||(h("pipe resume"),n.resume()),t},b.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function s(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function f(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function p(t){return t.toString(this.encoding)}function h(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(t.lastNeed=i-1),i;if(--r=0)return i>0&&(t.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,n){"use strict";t.exports=u;var r=n(4),i=n(8);function o(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length0?u-4:u;for(n=0;n>16&255,s[f++]=e>>8&255,s[f++]=255&e;2===a&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,s[f++]=255&e);1===a&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,s[f++]=e>>8&255,s[f++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],u=0,a=n-i;ua?a:u+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=u.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t,e,n){for(var i,o,u=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return u.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,i){var o,u,a=8*i-r-1,s=(1<>1,f=-7,l=n?i-1:0,p=n?-1:1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=p,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=r;f>0;u=256*u+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===s)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),o-=c}return(h?-1:1)*u*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var u,a,s,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=f):(u=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-u))<1&&(u--,s*=2),(e+=u+l>=1?p/s:p*Math.pow(2,1-l))*s>=2&&(u++,s/=2),u+l>=f?(a=0,u=f):u+l>=1?(a=(e*s-1)*Math.pow(2,i),u+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),u=0));i>=8;t[n+h]=255&a,h+=d,a/=256,i-=8);for(u=u<0;t[n+h]=255&u,h+=d,u/=256,c-=8);t[n+h-d]|=128*g}},function(t,e,n){var r=n(35),i=n(12),o=n(38),u=(n(13),function(t){this.options=t,this.debug=this.options.debug?console.log.bind(console):function(){},this.board=this.options.board});u.prototype._init=function(t){this._setUpSerial((function(e){return t(e)}))},u.prototype._setUpSerial=function(t){return this.serialPort=new r("",{baudRate:this.board.baud,autoOpen:!1}),t(null)},u.prototype._sniffPort=function(t){var e=this.board.productId.map((function(t){return parseInt(t,16)}));this._listPorts((function(n,r){var i=r.filter((function(t){return-1!==e.indexOf(parseInt(t._standardPid,16))}));return t(null,i)}))},u.prototype._setDTR=function(t,e,n){var r={rts:t,dtr:t};this.serialPort.set(r,(function(t){if(t)return n(t);setTimeout((function(){n(t)}),e)}))},u.prototype._pollForPort=function(t){var e=this,n=o((function(t){var n=!1;e._sniffPort((function(r,i){i.length&&(e.options.port=i[0].comName,n=!0),t(n)}))}));n.every(100).ask(15),n((function(n){if(!n)return t(new Error("could not reconnect after resetting board."));e.debug("found port on",e.options.port),e._setUpSerial((function(e){return t(e)}))}))},u.prototype._pollForOpen=function(t){var e=this,n=o((function(t){e.serialPort.open((function(e){t(!e)}))}));n.every(200).ask(10),n((function(n){var r;n||(r=new Error("could not open board on "+e.serialPort.path)),t(r)}))},u.prototype._cycleDTR=function(t){i.series([this._setDTR.bind(this,!0,250),this._setDTR.bind(this,!1,50)],(function(e){return t(e)}))},u.prototype._listPorts=function(t){var e=[];r.list((function(n,r){if(n)return t(n);for(var i=0;it(null,e)).catch(e=>t(e))}open(t){navigator.serial.requestPort(this.requestOptions).then(t=>(this.port=t,this.port.open({baudrate:this.baudrate||57600}))).then(()=>this.writer=this.port.writable.getWriter()).then(()=>this.reader=this.port.readable.getReader()).then(async()=>{for(this.emit("open"),t(null);this.port.readable;)try{for(;;){const{value:t,done:n}=await this.reader.read();if(n)break;this.emit("data",e.from(t))}}catch(t){console.log("ERROR while reading port:",t)}}).catch(e=>{t(e)})}close(t){if(this.port.close(),t)return t(null)}set(t,e){this.port.setSignals(t).then(()=>e(null)).catch(t=>e(t))}write(t,e){return this.writer.write(t),e(null)}read(t){this.reader.read().then(e=>t(null,e)).catch(e=>t(e))}flush(){this.port.flush()}}}).call(this,n(0).Buffer)},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,u,a,s=1,c={},f=!1,l=t.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(t);p=p&&p.setTimeout?p:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){o.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(t){var e=l.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(u="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(u)&&d(+e.data.slice(u.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),r=function(e){t.postMessage(u+e,"*")}),p.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=o?n&&(n=null,r(!!t)):(u&&(!0===u?e=i(e,c):e+=c*u),s=setTimeout(f,e))}return(e=function(t){if(s&&(clearTimeout(s),s=null,n&&n(!1),n=null,c=0),arguments.length){if(!r(t,"function"))throw new TypeError("done callback must be a function");n=t}s=setTimeout(f,a)}).ask=function(t){if(s)throw new SyntaxError("can not set ask limit during polling");if(!r(t,"number"))throw new TypeError("ask limit must be a number");return o=t,e},e.every=function(t){if(s)throw new SyntaxError("can not set timeout during polling");if(!r(t,"number"))throw new TypeError("timout must be a number");return a=t,e},e.incr=function(t){if(s)throw new SyntexError("can not set increment during polling");if(!arguments.length||r(t,"boolean"))u=!!t;else{if(!r(t,"number"))throw new TypeError("increment must be a boolean or number");u=t}return e},e}()}},function(t,e){t.exports=function(t,e){function n(e){return"object"==typeof t&&null!==t}function r(t){return t.name.toLowerCase()}switch(2===arguments.length&&void 0===e?e="undefined":Number.isNaN(e)&&(e="NaN"),e){case"boolean":case"function":case"string":return typeof t===e;case"number":return typeof t===e&&!isNaN(t);case Number:if(isNaN(t))return!1;case String:case Boolean:return typeof t===r(e);case Object:case"object":return n();case"array":return Array.isArray(t);case"regex":case"regexp":return t instanceof RegExp;case"date":return t instanceof Date;case"null":case null:return null===t;case"undefined":return void 0===t;case"NaN":return Number.isNaN(t);case"arguments":return!!n()&&("function"==typeof t.callee||/arguments/i.test(t.toString()));default:return"function"==typeof e?t instanceof e:t}}},function(t,e){t.exports=function(t,e){for(var n=0;n++>8&255,c={cmd:[i.Cmnd_STK_LOAD_ADDRESS,a,s],responseData:i.OK_RESPONSE,timeout:n};o(t,c,(function(t,e){u.log("loaded address",t,e),r(t,e)}))},u.prototype.loadPage=function(t,n,r,u){this.log("load page");var a=this,s=255&n.length,c=n.length>>8,f={cmd:e.concat([new e([i.Cmnd_STK_PROG_PAGE,c,s,70]),n,new e([i.Sync_CRC_EOP])]),responseData:i.OK_RESPONSE,timeout:r};o(t,f,(function(t,e){a.log("loaded page",t,e),u(t,e)}))},u.prototype.upload=function(t,e,n,i,o){this.log("program");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.loadPage(t,u,i,e)},function(t){c.log("programmed page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("page done"),o(t)}))}),(function(t){c.log("upload done"),o(t)}))},u.prototype.exitProgrammingMode=function(t,e,n){this.log("send leave programming mode");var r=this,u={cmd:[i.Cmnd_STK_LEAVE_PROGMODE],responseData:i.OK_RESPONSE,timeout:e};o(t,u,(function(t,e){r.log("sent leave programming mode",t,e),n(t,e)}))},u.prototype.verify=function(t,e,n,i,o){this.log("verify");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.verifyPage(t,u,n,i,e)},function(t){c.log("verified page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("verify done"),o(t)}))}),(function(t){c.log("verify done"),o(t)}))},u.prototype.verifyPage=function(t,n,r,u,a){this.log("verify page");var s=this;match=e.concat([new e([i.Resp_STK_INSYNC]),n,new e([i.Resp_STK_OK])]);var c=n.length>=r?r:n.length,f={cmd:[i.Cmnd_STK_READ_PAGE,c>>8&255,255&c,70],responseLength:match.length,timeout:u};o(t,f,(function(t,e){s.log("confirm page",t,e,e.toString("hex")),a(t,e)}))},u.prototype.bootload=function(t,e,n,i){var o={pagesizehigh:n.pagesizehigh<<8&255,pagesizelow:255&n.pagesizelow};r.series([this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.verifySignature.bind(this,t,n.signature,n.timeout),this.setOptions.bind(this,t,o,n.timeout),this.enterProgrammingMode.bind(this,t,n.timeout),this.upload.bind(this,t,e,n.pageSize,n.timeout),this.verify.bind(this,t,e,n.pageSize,n.timeout),this.exitProgrammingMode.bind(this,t,n.timeout)],(function(t){return i(t)}))},t.exports=u}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i;!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e){var r=n(14),i=n(46),o=n(15);t.exports=function(t,n,u){var a,s=n.timeout||0,c=(o.Resp_STK_INSYNC,o.Resp_STK_NOSYNC,null),f=0;n.responseData&&n.responseData.length>0&&(c=n.responseData),c&&(f=c.length),n.responseLength&&(f=n.responseLength);var l=n.cmd;l instanceof Array&&(l=new e(l.concat(o.Sync_CRC_EOP))),t.write(l,(function(e){if(e)return a=new Error("Sending "+l.toString("hex")+": "+e.message),u(a);i(t,s,f,(function(t,e){return t?(a=new Error("Sending "+l.toString("hex")+": "+t.message),u(a)):c&&!r(e,c)?(a=new Error(l+" response mismatch: "+e.toString("hex")+", "+c.toString("hex")),u(a)):void u(null,e)}))}))}}).call(this,n(0).Buffer)},function(t,e,n){(function(e){var r=[n(15).Resp_STK_INSYNC];t.exports=function(t,n,i,o){var u=new e(0),a=!1,s=null,c=function(t){for(var n=0;!a&&ni)return f(new Error("buffer overflow "+u.length+" > "+i));u.length==i&&f()},f=function(e){s&&clearTimeout(s),t.removeListener("data",c),o(e,u)};n&&n>0&&(s=setTimeout((function(){s=null,f(new Error("receiveData timeout after "+n+"ms"))}),n)),t.on("data",c)}}).call(this,n(0).Buffer)},function(t,e){var n={};t.exports=n;var r={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(r).forEach((function(t){var e=r[t],i=n[t]=[];i.open="["+e[0]+"m",i.close="["+e[1]+"m"}))},function(t,e,n){(function(e){var n=e.argv;t.exports=!(-1!==n.indexOf("--no-color")||-1!==n.indexOf("--color=false")||-1===n.indexOf("--color")&&-1===n.indexOf("--color=true")&&-1===n.indexOf("--color=always")&&(e.stdout&&!e.stdout.isTTY||"win32"!==e.platform&&!("COLORTERM"in e.env||"dumb"!==e.env.TERM&&/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(e.env.TERM))))}).call(this,n(1))},function(t,e){t.exports=function(t,e){var n="";t=(t=t||"Run the trap, drop the bass").split("");var r={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","۝","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return t.forEach((function(t){t=t.toLowerCase();var e=r[t]||[" "],i=Math.floor(Math.random()*e.length);n+=void 0!==r[t]?r[t][i]:t})),n}},function(t,e){t.exports=function(t,e){t=t||" he is here ";var n={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},r=[].concat(n.up,n.down,n.mid);function i(t){return Math.floor(Math.random()*t)}function o(t){var e=!1;return r.filter((function(n){e=n===t})),e}return function(t,e){var r,u,a="";for(u in(e=e||{}).up=void 0===e.up||e.up,e.mid=void 0===e.mid||e.mid,e.down=void 0===e.down||e.down,e.size=void 0!==e.size?e.size:"maxi",t=t.split(""))if(!o(u)){switch(a+=t[u],r={up:0,down:0,mid:0},e.size){case"mini":r.up=i(8),r.mid=i(2),r.down=i(8);break;case"maxi":r.up=i(16)+3,r.mid=i(4)+1,r.down=i(64)+3;break;default:r.up=i(8)+1,r.mid=i(6)/2,r.down=i(8)+1}var s=["up","mid","down"];for(var c in s)for(var f=s[c],l=0;l<=r[f];l++)e[f]&&(a+=n[f][i(n[f].length)])}return a}(t,e)}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){if(" "===t)return t;switch(e%3){case 0:return r.red(t);case 1:return r.white(t);case 2:return r.blue(t)}}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){return e%2==0?t:r.inverse(t)}},function(t,e,n){var r,i=n(5);t.exports=(r=["red","yellow","green","blue","magenta"],function(t,e,n){return" "===t?t:i[r[e++%r.length]](t)})},function(t,e,n){var r,i=n(5);t.exports=(r=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"],function(t,e,n){return" "===t?t:i[r[Math.round(Math.random()*(r.length-1))]](t)})},function(t,e,n){var r=n(5);t.exports=function(){var t=function(t,e){String.prototype.__defineGetter__(t,e)};function e(e){var n=["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","charAt","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","charCodeAt","indexOf","lastIndexof","length","localeCompare","match","replace","search","slice","split","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","trimLeft","trimRight"];Object.keys(e).forEach((function(i){-1!==n.indexOf(i)?console.log("warn: ".red+("String.prototype"+i).magenta+" is probably something you don't want to override. Ignoring style name"):"string"==typeof e[i]?(r[i]=r[e[i]],t(i,(function(){return r[e[i]](this)}))):t(i,(function(){for(var t=this,n=0;n=6){var r=n.message[5];i.writeUInt8(r,0)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,1,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,1)}t(e)}))},function(t){var r=new e([29,4,4,0,48,0,2,0]);n.parser.send(r,(function(e,n){if(n&&n.message&&n.message.length>=6){var r=n.message[5];i.writeUInt8(r,2)}t(e)}))}],(function(e){t(e,i)}))},d.prototype.enterProgrammingMode=function(t,n){var r=this,i=Array.prototype.slice.call(arguments);"function"!=typeof(n=i.pop())&&(n=null),(t="function"!=typeof t&&t||{}).timeout=t.timeout||a,t.stabDelay=t.stabDelay||s,t.cmdexeDelay=t.cmdexeDelay||c,t.synchLoops=t.synchLoops||f,t.byteDelay=t.byteDelay||l,t.pollValue=t.pollValue||p,t.pollIndex=t.pollIndex||h;var o=172,u=83,d=0,g=0,y=new e([16,t.timeout,t.stabDelay,t.cmdexeDelay,t.synchLoops,t.byteDelay,t.pollValue,t.pollIndex,o,u,d,g]);r.parser.send(y,(function(t,e){n(t)}))},d.prototype.loadAddress=function(t,n){msb=t>>24&255|128,xsb=t>>16&255,ysb=t>>8&255,lsb=255&t;var r=new e([6,msb,xsb,ysb,lsb]);this.parser.send(r,(function(t,e){n(t)}))},d.prototype.loadPage=function(t,n){var r=t.length>>8,i=255&t.length,o=new e([19,r,i,193,10,64,76,32,0,0]);o=e.concat([o,t]),this.parser.send(o,(function(t,e){n(t)}))},d.prototype.upload=function(t,e,n){var i,o,u=0,a=this;r.whilst((function(){return u>1,t()},function(t){a.loadAddress(o,t)},function(n){i=t.slice(u,t.length>e?u+e:t.length-1),n()},function(t){a.loadPage(i,t)},function(t){u+=i.length,setTimeout(t,4)}],(function(t){n(t)}))}),(function(t){n(t)}))},d.prototype.exitProgrammingMode=function(t){var n=new e([17,1,1]);this.parser.send(n,(function(e,n){t(e)}))},d.prototype.verify=function(t,e){e()},d.prototype.bootload=function(t,e,n){n()},t.exports=d}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i;!function(){var o,u,a={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(o,arguments)}}null!=(o=this)&&(u=o.async),a.noConflict=function(){return o.async=u,a};var c=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},l=function(t,e){for(var n=0;n=t.length&&n()}l(t,(function(t){e(t,s(i))}))},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],(function(e){e?(n(e),n=function(){}):(r+=1)>=t.length?n():i()}))};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){d(e).apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var d=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,u=0;!function a(){if(i>=e.length)return r();for(;u=e.length?r():a())}))}()}},g=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},v=function(t,e,n,r){if(e=p(e,(function(t,e){return{index:e,value:t}})),r){var i=[];t(e,(function(t,e){n(t.value,(function(n,r){i[t.index]=r,e(n)}))}),(function(t){r(t,i)}))}else t(e,(function(t,e){n(t.value,(function(t){e(t)}))}))};a.map=g(v),a.mapSeries=y(v),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[d(t)].concat(n))}}(t,v)};a.reduce=function(t,e,n,r){a.eachSeries(t,(function(t,r){n(e,t,(function(t,n){e=n,r(t)}))}),(function(t){r(t,e)}))},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=p(t,(function(t){return t})).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var b=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n&&i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.filter=g(b),a.filterSeries=y(b),a.select=a.filter,a.selectSeries=a.filterSeries;var w=function(t,e,n,r){var i=[];t(e=p(e,(function(t,e){return{index:e,value:t}})),(function(t,e){n(t.value,(function(n){n||i.push(t),e()}))}),(function(t){r(p(i.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))};a.reject=g(w),a.rejectSeries=y(w);var _=function(t,e,n,r){t(e,(function(t,e){n(t,(function(n){n?(r(t),r=function(){}):e()}))}),(function(t){r()}))};a.detect=g(_),a.detectSeries=y(_),a.some=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t&&(n(!0),n=function(){}),r()}))}),(function(t){n(!1)}))},a.any=a.some,a.every=function(t,e,n){a.each(t,(function(t,r){e(t,(function(t){t||(n(!1),n=function(){}),r()}))}),(function(t){n(!0)}))},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,(function(t,n){e(t,(function(e,r){e?n(e):n(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,p(e.sort((function(t,e){var n=t.criteria,r=e.criteria;return nr?1:0})),(function(t){return t.value})))}))},a.auto=function(t,e){e=e||function(){};var n=h(t),r=n.length;if(!r)return e();var i={},o=[],u=function(t){o.unshift(t)},s=function(){r--,l(o.slice(0),(function(t){t()}))};u((function(){if(!r){var t=e;e=function(){},t(null,i)}})),l(n,(function(n){var r=f(t[n])?t[n]:[t[n]],c=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var o={};l(h(i),(function(t){o[t]=i[t]})),o[n]=r,e(t,o),e=function(){}}else i[n]=r,a.setImmediate(s)},p=r.slice(0,Math.abs(r.length-1))||[],d=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},r=!0,((t=p).reduce?t.reduce(e,r):(l(t,(function(t,n,i){r=e(r,t,n,i)})),r))&&!i.hasOwnProperty(n);var t,e,r};if(d())r[r.length-1](c,i);else{var g=function(){d()&&(!function(t){for(var e=0;e>>1);n(e,t[o])>=0?r=o:i=o-1}return r}(t.tasks,o,n)+1,0,o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)}))}(r,t,e,i)},delete r.unshift,r},a.cargo=function(t,e){var n=!1,r=[],i={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){f(t)||(t=[t]),l(t,(function(t){r.push({data:t,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===e&&i.saturated()})),a.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var u="number"==typeof e?r.splice(0,e):r.splice(0,r.length),a=p(u,(function(t){return t.data}));i.empty&&i.empty(),n=!0,t(a,(function(){n=!1;var t=arguments;l(u,(function(e){e.callback&&e.callback.apply(null,t)})),o()}))}},length:function(){return r.length},running:function(){return n}};return i};var x=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(n,(function(e){console[t](e)})))}]))}};a.log=x("log"),a.dir=x("dir"),a.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),u=e.apply(null,i);u in n?a.nextTick((function(){o.apply(null,n[u])})):u in r?r[u].push(o):(r[u]=[o],t.apply(null,i.concat([function(){n[u]=arguments;var t=r[u];delete r[u];for(var e=0,i=t.length;e2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=g(T),a.applyEachSeries=y(T),a.forever=function(t,e){!function n(r){if(r){if(e)return e(r);throw r}t(n)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,n(1),n(7).setImmediate)},function(t,e,n){(function(e,r){var i=n(24),o=n(6).EventEmitter;t.exports=function(t){var n,u,a=(n=new o,u={constants:i,port:t,boundOpen:!1,closed:!1,_inc:-1,_queue:[],_current:!1,states:["Start","GetSequenceNumber","GetMessageSize1","GetMessageSize2","GetToken","GetData","GetChecksum","Done"],state:0,pkt:!1,send:function(t,n){if(this.closed)return e((function(){var t=new Error("this parser is closed.");t.code="E_CLOSED",n(t)}));r.isBuffer(t)||(t=new r(t));var o=this._commandTimeout(t[0]),u=new r([0,0]);u.writeUInt16BE(t.length,0);var a=r.concat([new r([i.MESSAGE_START,this._seq(),u[0],u[1],i.TOKEN]),t]),s=this.checksum(a);this._queue.push({buf:r.concat([a,new r([s])]),seq:this._inc,cb:n,timeout:o}),this._send()},checksum:function(t){for(var e=0,n=0;n255&&(this._inc=0),this._inc},_commandTimeout:function(t){if(timeout=1e3,t===i.CMD_SIGN_ON)timeout=200;else for(var e=Object.keys(i),n=0;n-1||e[n].indexOf("PROGRAM_FLASH")>-1||e[n].indexOf("EEPROM")>-1)&&(timeout=5e3);break}return timeout},_send:function(){if(this.closed)return!1;if(!this._current&&this._queue.length)if("function"==typeof t.isOpen?t.isOpen():t.isOpen){var e=this._queue.shift(),n=this._current={timeout:!1,seq:e.seq,cb:e.cb};this._current,this.state=0,r=this,this.port.write(e.buf),this.port.drain((function(){if(n!==r._current)return r.emit("log","current was no longer the current message after drain callback");n.timeout=setTimeout((function(){var t=new Error("stk500 timeout. "+e.timeout+"ms");t.code="E_TIMEOUT",r._resolveCurrent(t)}),e.timeout)})),this.emit("rawinput",e.buf)}else{var r=this;this.boundOpen||t.once("open",(function(){r._send()}))}},_handle:function(t){var e=this._current;if(this.emit("raw",t),!e)return this.emit("log","notice","dropping data","data");for(var n=0;n ");for(var n=0;n126)&&(r="."),e.stdout.write(r+" ["+t.readUInt8(n).toString(16)+"] ")}e.stdout.write("\n")})),this.c=function(t,e,n){return r.cmds.push({value:t,callback:function(t){e&&e(t)},expectedResponseLength:n}),this},this.flashChunkSize=0,this.bytes=[],this.cmds=[]},o.Flasher.prototype={run:function(t){var n=this;e.nextTick((function(){if(!n.running){var i=n.cmds.shift();if(i){running=!0,n.options.debug&&e.stdout.write("Send: "+i.value);var o=new r(0),u=function(a){o=r.concat([o,a]),(void 0===i.expectedResponseLength||i.expectedResponseLength<=o.length)&&(n.sp.removeListener("data",u),n.running=!1,i.callback(o),e.nextTick((function(){n.cmds.length>0?n.run(t):t&&t()})))};n.sp.on("data",u),n.sp.write(i.value)}}}))},prepare:function(t){var e=this;this.c("S",(function(n){n.toString()!==e.signature&&t(new Error("Invalid device signature; expecting: "+e.signature+" received: "+n.toString()))})).c("V").c("v").c("p").c("a").c("b",(function(n){"Y"!=(n.toString()||"X")[0]&&t(new Error("Buffered memory access not supported.")),e.flashChunkSize=n.readUInt16BE(1)})).c("t").c("TD").c("P").c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c([u("A"),3,252]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]).c([u("A"),3,255]).c([u("g"),0,1,u("E")]),this.run((function(){t(null,e)}))},erase:function(t){this.c("e",(function(){t&&t()})),this.run()},program:function(t,e){var n,r=this,o=[];this.totalBytes=0,this.c([u("A"),0,0],(function(){n=i.parse(t),r.totalBytes=n.data.length,Array.prototype.push.apply(o,n.data),r.allBytes=o,r.options.debug&&console.log("programming",o.length,"bytes"),r.chunksSent=[];for(var e=0;e>8&255,255&a.length,u("F")].concat(a))}})),this.run((function(){e&&e()}))},verify:function(t){var n=this;this.c([u("A"),0,0],(function(){var r=0,i=function(o){var a=null;if(r++,n.allBytes.length){var s=o.length;if(n.allBytes.splice(0,s).forEach((function(t,e){t!==o.readUInt8(e)&&(a=new Error("Firmware on the device does not match local data"))})),a)return t(a);e.nextTick((function(){var t=n.flashChunkSize;n.options.debug&&console.log(n.totalBytes-r*n.flashChunkSize),n.totalBytes-r*n.flashChunkSize>8&255,255&t,u("F")],i,t),n.run()}))}else t&&t()};n.options.debug&&console.log("\n\nVerifying flash.."),n.c([u("g"),n.flashChunkSize>>8&255,255&n.flashChunkSize,u("F")],i,n.flashChunkSize),n.run()})),n.run()},fuseCheck:fuseCheck=function(t){this.options.debug&&console.log("checking fuses"),this.c("F").c("F").c("F").c("N").c("N").c("N").c("Q").c("Q").c("Q").c("L").c("E"),this.run((function(){t()}))}},o.init=function(t,e,n){"function"!=typeof e||n||(n=e,e={}),new o.Flasher(t,e).prepare(n)}}).call(this,n(1),n(0).Buffer)},function(t,e,n){t.exports=i;var r=n(6).EventEmitter;function i(){r.call(this)}n(3)(i,r),i.Readable=n(18),i.Writable=n(69),i.Duplex=n(70),i.Transform=n(71),i.PassThrough=n(72),i.Stream=i,i.prototype.pipe=function(t,e){var n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(n.on("end",a),n.on("close",s));var u=!1;function a(){u||(u=!0,t.end())}function s(){u||(u=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===r.listenerCount(this,"error"))throw t}function f(){n.removeListener("data",i),t.removeListener("drain",o),n.removeListener("end",a),n.removeListener("close",s),n.removeListener("error",c),t.removeListener("error",c),n.removeListener("end",f),n.removeListener("close",f),t.removeListener("close",f)}return n.on("error",c),t.on("error",c),n.on("end",f),n.on("close",f),t.on("close",f),t.emit("pipe",n),t}},function(t,e){},function(t,e,n){"use strict";var r=n(11).Buffer,i=n(66);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var e,n,i,o=r.allocUnsafe(t>>>0),u=this.head,a=0;u;)e=u.data,n=o,i=a,e.copy(n,i),a+=u.data.length,u=u.next;return o},t}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}}).call(this,n(2))},function(t,e,n){"use strict";t.exports=o;var r=n(29),i=n(8);function o(t){if(!(this instanceof o))return new o(t);r.call(this,t)}i.inherits=n(3),i.inherits(o,r),o.prototype._transform=function(t,e,n){n(null,t)}},function(t,e,n){t.exports=n(19)},function(t,e,n){t.exports=n(4)},function(t,e,n){t.exports=n(18).Transform},function(t,e,n){t.exports=n(18).PassThrough},function(t,e){},function(t,e){t.exports=function(t,e,n){var r=function(r){if(r=r||{},this.options={debug:r.debug||!1,board:r.board||"uno",port:r.port||"",manualReset:r.manualReset||!1},!0===this.options.debug?this.debug=console.log.bind(console):"function"==typeof this.options.debug?this.debug=this.options.debug:this.debug=function(){},"string"==typeof this.options.board?this.options.board=t[this.options.board]:"object"==typeof this.options.board&&(this.options.board=this.options.board),this.options.board&&!this.options.board.manualReset&&(this.options.board.manualReset=this.options.manualReset),this.connection=new e(this.options),this.options.board){var i=n[this.options.board.protocol]||function(){};this.protocol=new i({board:this.options.board,connection:this.connection,debug:this.debug})}};return r.prototype._validateBoard=function(t){if("object"!=typeof this.options.board)return t(new Error('"'+this.options.board+'" is not a supported board type.'));if(this.protocol.chip)return this.options.port||"pro-mini"!==this.options.board.name?t(null):t(new Error("using a pro-mini, please specify the port in your options."));var e="not a supported programming protocol: "+this.options.board.protocol;return t(new Error(e))},r.prototype.flash=function(t,e){var n=this;n._validateBoard((function(r){if(r)return e(r);n.connection._init((function(r){if(r)return e(r);n.protocol._upload(t,e)}))}))},r.prototype.listPorts=r.listPorts=r.prototype.list=r.list=function(t){return e.prototype._listPorts(t)},r.listKnownBoards=function(){return Object.keys(t).filter((function(e){var n=t[e].aliases;return!n||!~n.indexOf(e)}))},r}}])})); \ No newline at end of file diff --git a/dist/avrgirl-arduino.min.js.LICENSE b/dist/avrgirl-arduino.min.js.LICENSE new file mode 100644 index 0000000..4178754 --- /dev/null +++ b/dist/avrgirl-arduino.min.js.LICENSE @@ -0,0 +1,14 @@ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */ diff --git a/index.html b/index.html new file mode 100644 index 0000000..80a7d4f --- /dev/null +++ b/index.html @@ -0,0 +1,65 @@ + + + + avrgirl test + + +

hello!

+

Choose a file to upload to an arduino

+ +
+ + + + + +
+ + + + + diff --git a/lib/browser-serialport.js b/lib/browser-serialport.js index ea48e95..775863c 100644 --- a/lib/browser-serialport.js +++ b/lib/browser-serialport.js @@ -1,20 +1,29 @@ const { EventEmitter } = require('events'); class SerialPort extends EventEmitter { - constructor(options) { + constructor(port, options) { super(options); this.options = options || {}; + this.browser = true; this.path = this.options.path; this.port = null; this.writer = null; this.reader = null; this.baudrate = this.options.baudRate; + this.requestOptions = this.options.requestOptions || {}; - // not sure what needs to go into this options object (perhaps pid / vid filters like webusb?) - var requestOptions = {}; + if (this.options.autoOpen) this.open(); + } - navigator.serial.requestPort(requestOptions) + list(callback) { + navigator.serial.getPorts() + .then((list) => callback(null, list)) + .catch((error) => callback(error)); + } + + open(callback) { + navigator.serial.requestPort(this.requestOptions) .then(serialPort => { this.port = serialPort; return this.port.open({ baudrate: this.baudrate || 57600 }); @@ -23,52 +32,31 @@ class SerialPort extends EventEmitter { .then(() => this.reader = this.port.readable.getReader()) .then(async () => { this.emit('open'); + callback(null); while (this.port.readable) { try { while (true) { const { value, done } = await this.reader.read(); - this.emit('data', value); if (done) { break; } + this.emit('data', Buffer.from(value)); } } catch (e) { - term.writeln(``); + console.log('ERROR while reading port:', e); } } }) - .catch(error => {throw new Error(error)}); - } - - list(callback) { - navigator.serial.getPorts() - .then((list) => callback(null, list)) - .catch((error) => callback(error)); - } - - open(callback) { - this.port.open({baudrate: this.boardrate}) - .then(() => callback(null)) - .catch((error) => callback(error)); + .catch(error => {callback(error)}); } close(callback) { - this.port.close() - .then(() => callback(null)) - .catch((error) => callback(error)); + this.port.close(); + if (callback) return callback(null); } set(props, callback) { - // I'm not entirely sure the remappings below are correct - // TODO: read the serial spec to be sure - const remappedSignals = { - signals: { - dsr: props.dtr, - ri: props.rts - } - }; - - this.port.setControlSignals(remappedSignals) + this.port.setSignals(props) .then(() => callback(null)) .catch((error) => callback(error)); } diff --git a/lib/connection-browser.js b/lib/connection-browser.js index 68ec248..386c7d4 100644 --- a/lib/connection-browser.js +++ b/lib/connection-browser.js @@ -1,6 +1,7 @@ var Serialport = require('./browser-serialport'); var async = require('async'); var awty = require('awty'); +var tools = require('./tools'); var Connection = function(options) { this.options = options; @@ -10,41 +11,16 @@ var Connection = function(options) { }; Connection.prototype._init = function(callback) { - var _this = this; - - // check for port - if (!_this.options.port) { - // no port, auto sniff for the correct one - _this._sniffPort(function(error, port) { - if (port.length) { - // found a port, save it - _this.options.port = port[0].comName; - - _this.debug('found ' + _this.options.board.name + ' on port ' + _this.options.port); - - // set up serialport for it - _this._setUpSerial(function(error) { - return callback(error); - }); - } else { - // we didn't find the board - return callback(new Error('no Arduino ' + '\'' + _this.options.board.name + '\'' + ' found.')); - } - }); - - } else { - // when a port is manually specified - _this._setUpSerial(function(error) { - return callback(error); - }); - } + this._setUpSerial(function(error) { + return callback(error); + }); }; /** * Create new serialport instance for the Arduino board, but do not immediately connect. */ Connection.prototype._setUpSerial = function(callback) { - this.serialPort = new Serialport(this.options.port, { + this.serialPort = new Serialport('', { baudRate: this.board.baud, autoOpen: false }); diff --git a/lib/tools.js b/lib/tools.js index ce52b2c..b0b22f0 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -14,7 +14,8 @@ tools._parseHex = function(file) { encoding: 'utf8' }); } else { - data = file; + // ensure compatibility with browser array buffers + data = Buffer.from(file); } return intelhex.parse(data).data; @@ -23,4 +24,8 @@ tools._parseHex = function(file) { } }; +tools._hexStringToByte = function(str) { + return Buffer.from([parseInt(str,16)]); +} + module.exports = tools; diff --git a/package-lock.json b/package-lock.json index c557434..b4cd376 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,6 +53,224 @@ "safe-buffer": "^5.1.1" } }, + "@webassemblyjs/ast": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz", + "integrity": "sha512-aJMfngIZ65+t71C3y2nBBg5FFG0Okt9m0XEgWZ7Ywgn1oMAT8cNwx00Uv1cQyHtidq0Xn94R4TAywO+LCQ+ZAQ==", + "dev": true, + "requires": { + "@webassemblyjs/helper-module-context": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/wast-parser": "1.8.5" + } + }, + "@webassemblyjs/floating-point-hex-parser": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.8.5.tgz", + "integrity": "sha512-9p+79WHru1oqBh9ewP9zW95E3XAo+90oth7S5Re3eQnECGq59ly1Ri5tsIipKGpiStHsUYmY3zMLqtk3gTcOtQ==", + "dev": true + }, + "@webassemblyjs/helper-api-error": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.8.5.tgz", + "integrity": "sha512-Za/tnzsvnqdaSPOUXHyKJ2XI7PDX64kWtURyGiJJZKVEdFOsdKUCPTNEVFZq3zJ2R0G5wc2PZ5gvdTRFgm81zA==", + "dev": true + }, + "@webassemblyjs/helper-buffer": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.8.5.tgz", + "integrity": "sha512-Ri2R8nOS0U6G49Q86goFIPNgjyl6+oE1abW1pS84BuhP1Qcr5JqMwRFT3Ah3ADDDYGEgGs1iyb1DGX+kAi/c/Q==", + "dev": true + }, + "@webassemblyjs/helper-code-frame": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.8.5.tgz", + "integrity": "sha512-VQAadSubZIhNpH46IR3yWO4kZZjMxN1opDrzePLdVKAZ+DFjkGD/rf4v1jap744uPVU6yjL/smZbRIIJTOUnKQ==", + "dev": true, + "requires": { + "@webassemblyjs/wast-printer": "1.8.5" + } + }, + "@webassemblyjs/helper-fsm": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.8.5.tgz", + "integrity": "sha512-kRuX/saORcg8se/ft6Q2UbRpZwP4y7YrWsLXPbbmtepKr22i8Z4O3V5QE9DbZK908dh5Xya4Un57SDIKwB9eow==", + "dev": true + }, + "@webassemblyjs/helper-module-context": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.8.5.tgz", + "integrity": "sha512-/O1B236mN7UNEU4t9X7Pj38i4VoU8CcMHyy3l2cV/kIF4U5KoHXDVqcDuOs1ltkac90IM4vZdHc52t1x8Yfs3g==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "mamacro": "^0.0.3" + } + }, + "@webassemblyjs/helper-wasm-bytecode": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.8.5.tgz", + "integrity": "sha512-Cu4YMYG3Ddl72CbmpjU/wbP6SACcOPVbHN1dI4VJNJVgFwaKf1ppeFJrwydOG3NDHxVGuCfPlLZNyEdIYlQ6QQ==", + "dev": true + }, + "@webassemblyjs/helper-wasm-section": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.8.5.tgz", + "integrity": "sha512-VV083zwR+VTrIWWtgIUpqfvVdK4ff38loRmrdDBgBT8ADXYsEZ5mPQ4Nde90N3UYatHdYoDIFb7oHzMncI02tA==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-buffer": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/wasm-gen": "1.8.5" + } + }, + "@webassemblyjs/ieee754": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.8.5.tgz", + "integrity": "sha512-aaCvQYrvKbY/n6wKHb/ylAJr27GglahUO89CcGXMItrOBqRarUMxWLJgxm9PJNuKULwN5n1csT9bYoMeZOGF3g==", + "dev": true, + "requires": { + "@xtuc/ieee754": "^1.2.0" + } + }, + "@webassemblyjs/leb128": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.8.5.tgz", + "integrity": "sha512-plYUuUwleLIziknvlP8VpTgO4kqNaH57Y3JnNa6DLpu/sGcP6hbVdfdX5aHAV716pQBKrfuU26BJK29qY37J7A==", + "dev": true, + "requires": { + "@xtuc/long": "4.2.2" + } + }, + "@webassemblyjs/utf8": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.8.5.tgz", + "integrity": "sha512-U7zgftmQriw37tfD934UNInokz6yTmn29inT2cAetAsaU9YeVCveWEwhKL1Mg4yS7q//NGdzy79nlXh3bT8Kjw==", + "dev": true + }, + "@webassemblyjs/wasm-edit": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.8.5.tgz", + "integrity": "sha512-A41EMy8MWw5yvqj7MQzkDjU29K7UJq1VrX2vWLzfpRHt3ISftOXqrtojn7nlPsZ9Ijhp5NwuODuycSvfAO/26Q==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-buffer": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/helper-wasm-section": "1.8.5", + "@webassemblyjs/wasm-gen": "1.8.5", + "@webassemblyjs/wasm-opt": "1.8.5", + "@webassemblyjs/wasm-parser": "1.8.5", + "@webassemblyjs/wast-printer": "1.8.5" + } + }, + "@webassemblyjs/wasm-gen": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.8.5.tgz", + "integrity": "sha512-BCZBT0LURC0CXDzj5FXSc2FPTsxwp3nWcqXQdOZE4U7h7i8FqtFK5Egia6f9raQLpEKT1VL7zr4r3+QX6zArWg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/ieee754": "1.8.5", + "@webassemblyjs/leb128": "1.8.5", + "@webassemblyjs/utf8": "1.8.5" + } + }, + "@webassemblyjs/wasm-opt": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.8.5.tgz", + "integrity": "sha512-HKo2mO/Uh9A6ojzu7cjslGaHaUU14LdLbGEKqTR7PBKwT6LdPtLLh9fPY33rmr5wcOMrsWDbbdCHq4hQUdd37Q==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-buffer": "1.8.5", + "@webassemblyjs/wasm-gen": "1.8.5", + "@webassemblyjs/wasm-parser": "1.8.5" + } + }, + "@webassemblyjs/wasm-parser": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.8.5.tgz", + "integrity": "sha512-pi0SYE9T6tfcMkthwcgCpL0cM9nRYr6/6fjgDtL6q/ZqKHdMWvxitRi5JcZ7RI4SNJJYnYNaWy5UUrHQy998lw==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-api-error": "1.8.5", + "@webassemblyjs/helper-wasm-bytecode": "1.8.5", + "@webassemblyjs/ieee754": "1.8.5", + "@webassemblyjs/leb128": "1.8.5", + "@webassemblyjs/utf8": "1.8.5" + } + }, + "@webassemblyjs/wast-parser": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.8.5.tgz", + "integrity": "sha512-daXC1FyKWHF1i11obK086QRlsMsY4+tIOKgBqI1lxAnkp9xe9YMcgOxm9kLe+ttjs5aWV2KKE1TWJCN57/Btsg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/floating-point-hex-parser": "1.8.5", + "@webassemblyjs/helper-api-error": "1.8.5", + "@webassemblyjs/helper-code-frame": "1.8.5", + "@webassemblyjs/helper-fsm": "1.8.5", + "@xtuc/long": "4.2.2" + } + }, + "@webassemblyjs/wast-printer": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.8.5.tgz", + "integrity": "sha512-w0U0pD4EhlnvRyeJzBqaVSJAo9w/ce7/WPogeXLzGkO6hzhr4GnQIZ4W4uUt5b9ooAaXPtnXlj0gzsXEOUNYMg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/wast-parser": "1.8.5", + "@xtuc/long": "4.2.2" + } + }, + "@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", + "dev": true + }, + "@xtuc/long": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", + "dev": true + }, + "acorn": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", + "dev": true + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-errors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", + "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==", + "dev": true + }, + "ajv-keywords": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.1.tgz", + "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==", + "dev": true + }, "ansi-bgblack": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-bgblack/-/ansi-bgblack-0.1.1.tgz", @@ -483,6 +701,44 @@ "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, + "asn1.js": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "dev": true, + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "assert": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", + "dev": true, + "requires": { + "object-assign": "^4.1.1", + "util": "0.10.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + } + } + } + }, "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", @@ -1037,6 +1293,18 @@ "pascalcase": "^0.1.1" } }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", + "dev": true + }, + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true + }, "binary-extensions": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.12.0.tgz", @@ -1057,6 +1325,18 @@ "safe-buffer": "^5.1.1" } }, + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", + "dev": true + }, + "bn.js": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", + "dev": true + }, "body-parser": { "version": "1.18.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", @@ -1222,10 +1502,98 @@ "to-regex": "^3.0.1" } }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true + }, "browser-serialport": { "version": "git+https://github.com/noopkat/browser-serialport.git#c8628c41c11890d3058875994c15f83f2df8185b", "from": "git+https://github.com/noopkat/browser-serialport.git#c8628c41c11890d3058875994c15f83f2df8185b" }, + "browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "dev": true, + "requires": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "dev": true, + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "dev": true, + "requires": { + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" + } + }, + "browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "dev": true, + "requires": { + "pako": "~1.0.5" + } + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, "buffer-alloc": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", @@ -1262,18 +1630,81 @@ "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", "dev": true }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "dev": true + }, "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true }, + "builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "dev": true + }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", "dev": true }, + "cacache": { + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.3.tgz", + "integrity": "sha512-kqdmfXEGFepesTuROHMs3MpFLWrPkSSpRqOw80RCflZXy/khxaArvFrQ7uJxSUduzAufc6G0g1VUCOZXxWavPw==", + "dev": true, + "requires": { + "bluebird": "^3.5.5", + "chownr": "^1.1.1", + "figgy-pudding": "^3.5.1", + "glob": "^7.1.4", + "graceful-fs": "^4.1.15", + "infer-owner": "^1.0.3", + "lru-cache": "^5.1.1", + "mississippi": "^3.0.0", + "mkdirp": "^0.5.1", + "move-concurrently": "^1.0.1", + "promise-inflight": "^1.0.1", + "rimraf": "^2.6.3", + "ssri": "^6.0.1", + "unique-filename": "^1.1.1", + "y18n": "^4.0.0" + }, + "dependencies": { + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + } + } + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -1369,6 +1800,25 @@ "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" }, + "chrome-trace-event": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz", + "integrity": "sha512-9e/zx1jw7B4CO+c/RXoCsfg/x1AfUBioy4owYH0bJprEYAx5hRFLRhWBqHAG57D0ZM4H7vxbP7bPe0VwhQRYDQ==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -1519,6 +1969,21 @@ "object-visit": "^1.0.0" } }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, "color-support": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", @@ -1535,6 +2000,12 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.18.0.tgz", "integrity": "sha512-6CYPa+JP2ftfRU2qkDK+UTVeQYosOg/2GbcjIcKPHfinyOLPVGXu/ovN86RP49Re5ndJK1N0kuiidFFuepc4ZQ==" }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, "component-emitter": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", @@ -1558,11 +2029,26 @@ "typedarray": "^0.0.6" } }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, + "constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", + "dev": true + }, "convert-source-map": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", @@ -1572,6 +2058,20 @@ "safe-buffer": "~5.1.1" } }, + "copy-concurrently": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", + "integrity": "sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A==", + "dev": true, + "requires": { + "aproba": "^1.1.1", + "fs-write-stream-atomic": "^1.0.8", + "iferr": "^0.1.5", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.4", + "run-queue": "^1.0.0" + } + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -1592,6 +2092,81 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "create-ecdh": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" + } + }, + "create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "dev": true, + "requires": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "dev": true, + "requires": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + } + }, + "cyclist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz", + "integrity": "sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=", + "dev": true + }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", @@ -1601,6 +2176,12 @@ "es5-ext": "^0.10.9" } }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, "debug": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.5.tgz", @@ -1671,6 +2252,16 @@ "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, + "des.js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", + "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, "detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", @@ -1688,6 +2279,23 @@ "integrity": "sha512-QpVuMTEoJMF7cKzi6bvWhRulU1fZqZnvyVQgNhPaxxuTYwyjn/j1v9falseQ/uXWwPnO56RBfwtg4h/EQXmucA==", "dev": true }, + "diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "domain-browser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", + "dev": true + }, "duplexer": { "version": "0.1.1", "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", @@ -1716,14 +2324,61 @@ "object.defaults": "^1.1.0" } }, - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "elliptic": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.1.tgz", + "integrity": "sha512-xvJINNLbTeWQjrl6X+7eQCrIy/YPv5XCpKW6kB5mKvtnGILoLDcySuwomfdzt0BMdLNVnuRNTuzKNHj0bva1Cg==", + "dev": true, + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true + }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "requires": { "once": "^1.4.0" } }, + "enhanced-resolve": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz", + "integrity": "sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "tapable": "^1.0.0" + } + }, + "errno": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "dev": true, + "requires": { + "prr": "~1.0.1" + } + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -1788,6 +2443,62 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", + "integrity": "sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA==", + "dev": true + }, + "evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "dev": true, + "requires": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -1942,6 +2653,24 @@ "time-stamp": "^1.0.0" } }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "figgy-pudding": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", + "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==", + "dev": true + }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", @@ -1984,6 +2713,62 @@ } } }, + "find-cache-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.0.0.tgz", + "integrity": "sha512-t7ulV1fmbxh5G9l/492O1p5+EBbr3uwpt6odhFTMc+nWyhmbloe+ja9BZ8pIBtqFWhOmCWVjx+pTW4zDkFoclw==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.0", + "pkg-dir": "^4.1.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + } + } + }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", @@ -2077,6 +2862,16 @@ "map-cache": "^0.2.2" } }, + "from2": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", + "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.0" + } + }, "fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -2092,6 +2887,18 @@ "through2": "^2.0.3" } }, + "fs-write-stream-atomic": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", + "integrity": "sha1-tH31NJPvkR33VzHnCp3tAYnbQMk=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "iferr": "^0.1.5", + "imurmurhash": "^0.1.4", + "readable-stream": "1 || 2" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2654,6 +3461,27 @@ "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", "dev": true }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + }, + "dependencies": { + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + } + } + }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -4416,6 +5244,12 @@ "ansi-regex": "^2.0.0" } }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, "has-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", @@ -4479,6 +5313,37 @@ } } }, + "hash-base": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "dev": true, + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "homedir-polyfill": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", @@ -4494,12 +5359,52 @@ "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", "dev": true }, + "https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", + "dev": true + }, "iconv-lite": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", "dev": true }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", + "dev": true + }, + "iferr": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", + "integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=", + "dev": true + }, + "import-local": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", + "integrity": "sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ==", + "dev": true, + "requires": { + "pkg-dir": "^3.0.0", + "resolve-cwd": "^2.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "infer-owner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", + "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -4693,6 +5598,12 @@ "is-unc-path": "^1.0.0" } }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, "is-unc-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", @@ -4719,6 +5630,12 @@ "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -5942,6 +6859,27 @@ } } }, + "jest-worker": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz", + "integrity": "sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==", + "dev": true, + "requires": { + "merge-stream": "^2.0.0", + "supports-color": "^6.1.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "jshint": { "version": "2.9.5", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.5.tgz", @@ -6311,6 +7249,18 @@ } } }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, "json-stable-stringify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", @@ -6320,6 +7270,15 @@ "jsonify": "~0.0.0" } }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", @@ -6422,6 +7381,41 @@ "strip-bom": "^2.0.0" } }, + "loader-runner": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", + "integrity": "sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw==", + "dev": true + }, + "loader-utils": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", + "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^2.0.0", + "json5": "^1.0.1" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "dependencies": { + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + } + } + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", @@ -6469,6 +7463,32 @@ "integrity": "sha512-mQuW55GhduF3ppo+ZRUTz1PRjEh1hS5BbqU7d8D0ez2OKxHDod7StPPeAVKisZR5aLkHZjdGWSL42LSONUJsZw==", "dev": true }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "requires": { + "yallist": "^3.0.2" + } + }, + "make-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.0.tgz", + "integrity": "sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "make-iterator": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", @@ -6486,6 +7506,21 @@ } } }, + "mamacro": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/mamacro/-/mamacro-0.0.3.tgz", + "integrity": "sha512-qMEwh+UujcQ+kbz3T6V+wAmO2U8veoq2w+3wY8MquqwVA3jChfwY+Tk52GZKDfACEPjuZ7r2oJLejwpt8jtwTA==", + "dev": true + }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -6512,6 +7547,44 @@ "stack-trace": "0.0.10" } }, + "md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "dev": true, + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + } + }, + "memory-fs": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", + "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -6570,11 +7643,39 @@ } } }, + "miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dev": true, + "requires": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -6589,20 +7690,50 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, - "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "mississippi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-3.0.0.tgz", + "integrity": "sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA==", "dev": true, "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" + "concat-stream": "^1.5.0", + "duplexify": "^3.4.2", + "end-of-stream": "^1.1.0", + "flush-write-stream": "^1.0.0", + "from2": "^2.1.0", + "parallel-transform": "^1.1.0", + "pump": "^3.0.0", + "pumpify": "^1.3.3", + "stream-each": "^1.1.0", + "through2": "^2.0.0" }, "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + } + } + }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { "is-plain-object": "^2.0.4" @@ -6641,6 +7772,20 @@ } } }, + "move-concurrently": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", + "integrity": "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=", + "dev": true, + "requires": { + "aproba": "^1.1.1", + "copy-concurrently": "^1.0.0", + "fs-write-stream-atomic": "^1.0.8", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.4", + "run-queue": "^1.0.3" + } + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -6718,12 +7863,24 @@ } } }, + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", + "dev": true + }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, "nise": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/nise/-/nise-1.2.0.tgz", @@ -6770,6 +7927,45 @@ "semver": "^5.4.1" } }, + "node-libs-browser": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", + "integrity": "sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q==", + "dev": true, + "requires": { + "assert": "^1.1.1", + "browserify-zlib": "^0.2.0", + "buffer": "^4.3.0", + "console-browserify": "^1.1.0", + "constants-browserify": "^1.0.0", + "crypto-browserify": "^3.11.0", + "domain-browser": "^1.1.1", + "events": "^3.0.0", + "https-browserify": "^1.0.0", + "os-browserify": "^0.3.0", + "path-browserify": "0.0.1", + "process": "^0.11.10", + "punycode": "^1.2.4", + "querystring-es3": "^0.2.0", + "readable-stream": "^2.3.3", + "stream-browserify": "^2.0.1", + "stream-http": "^2.7.2", + "string_decoder": "^1.0.0", + "timers-browserify": "^2.0.4", + "tty-browserify": "0.0.0", + "url": "^0.11.0", + "util": "^0.11.0", + "vm-browserify": "^1.0.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + } + } + }, "noop-logger": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", @@ -6805,6 +8001,15 @@ "once": "^1.3.2" } }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", @@ -6983,6 +8188,12 @@ "readable-stream": "^2.0.1" } }, + "os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", + "dev": true + }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", @@ -6997,6 +8208,79 @@ "lcid": "^1.0.0" } }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", + "dev": true + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "pako": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", + "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==", + "dev": true + }, + "parallel-transform": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.2.0.tgz", + "integrity": "sha512-P2vSmIu38uIlvdcU7fDkyrxj33gTUy/ABO5ZUbGowxNCopBq/OoD42bP4UmMrJoPyk4Uqf0mu3mtWBhHCZD8yg==", + "dev": true, + "requires": { + "cyclist": "^1.0.1", + "inherits": "^2.0.3", + "readable-stream": "^2.1.5" + } + }, + "parse-asn1": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", + "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", + "dev": true, + "requires": { + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, "parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", @@ -7035,6 +8319,12 @@ "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", "dev": true }, + "path-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", + "dev": true + }, "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", @@ -7056,6 +8346,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", @@ -7088,6 +8384,19 @@ "pinkie-promise": "^2.0.0" } }, + "pbkdf2": { + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", + "dev": true, + "requires": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -7109,6 +8418,26 @@ "pinkie": "^2.0.0" } }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + } + } + }, "plugin-error": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz", @@ -7223,6 +8552,12 @@ "plur": "^1.0.0" } }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "dev": true + }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", @@ -7233,6 +8568,12 @@ "resolved": "https://registry.npmjs.org/promirepl/-/promirepl-1.0.1.tgz", "integrity": "sha1-KVGq66K/P+InT/Y6FtlMBMpghy4=" }, + "promise-inflight": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", + "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", + "dev": true + }, "prompt-actions": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/prompt-actions/-/prompt-actions-3.0.2.tgz", @@ -7456,6 +8797,26 @@ } } }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "dev": true + }, + "public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, "pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", @@ -7476,6 +8837,24 @@ "pump": "^2.0.0" } }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "dev": true + }, + "querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", + "dev": true + }, "radio-symbol": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/radio-symbol/-/radio-symbol-2.0.0.tgz", @@ -7486,6 +8865,25 @@ "is-windows": "^1.0.1" } }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, + "requires": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, "raw-body": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", @@ -7809,6 +9207,15 @@ "path-parse": "^1.0.5" } }, + "resolve-cwd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", + "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", + "dev": true, + "requires": { + "resolve-from": "^3.0.0" + } + }, "resolve-dir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", @@ -7819,6 +9226,12 @@ "global-modules": "^1.0.0" } }, + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + }, "resolve-options": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", @@ -7840,6 +9253,34 @@ "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "dev": true }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "dev": true, + "requires": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, + "run-queue": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", + "integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=", + "dev": true, + "requires": { + "aproba": "^1.1.1" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -7860,6 +9301,17 @@ "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, + "schema-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz", + "integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==", + "dev": true, + "requires": { + "ajv": "^6.1.0", + "ajv-errors": "^1.0.0", + "ajv-keywords": "^3.1.0" + } + }, "semver": { "version": "5.5.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", @@ -7874,6 +9326,12 @@ "sver-compat": "^1.5.0" } }, + "serialize-javascript": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.0.tgz", + "integrity": "sha512-a/mxFfU00QT88umAJQsNWOnUKckhNCqOl028N48e7wFmo2/EHpTo9Wso+iJJCMrQnmFvcjto5RJdAHEvVhcyUQ==", + "dev": true + }, "serialport": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/serialport/-/serialport-6.2.2.tgz", @@ -7920,6 +9378,22 @@ "split-string": "^3.0.1" } }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "dev": true + }, + "sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "shallow-clone": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-1.0.0.tgz", @@ -7930,6 +9404,21 @@ "mixin-object": "^2.0.1" } }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -8106,6 +9595,12 @@ } } }, + "source-list-map": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", + "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==", + "dev": true + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -8125,6 +9620,24 @@ "urix": "^0.1.0" } }, + "source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "source-map-url": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", @@ -8208,6 +9721,15 @@ } } }, + "ssri": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", + "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", + "dev": true, + "requires": { + "figgy-pudding": "^3.5.1" + } + }, "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -8321,12 +9843,45 @@ } } }, + "stream-browserify": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", + "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", + "dev": true, + "requires": { + "inherits": "~2.0.1", + "readable-stream": "^2.0.2" + } + }, + "stream-each": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.3.tgz", + "integrity": "sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "stream-shift": "^1.0.0" + } + }, "stream-exhaust": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==", "dev": true }, + "stream-http": { + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", + "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", + "dev": true, + "requires": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.3.6", + "to-arraybuffer": "^1.0.0", + "xtend": "^4.0.0" + } + }, "stream-shift": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", @@ -8373,6 +9928,12 @@ "resolved": "https://registry.npmjs.org/strip-color/-/strip-color-0.1.0.tgz", "integrity": "sha1-EG9l09PmotlAHKwOsM6LinArT3s=" }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -8459,6 +10020,12 @@ "through2": "^2.0.0" } }, + "tapable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", + "dev": true + }, "tape": { "version": "4.8.0", "resolved": "https://registry.npmjs.org/tape/-/tape-4.8.0.tgz", @@ -8793,6 +10360,65 @@ } } }, + "terser": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.3.1.tgz", + "integrity": "sha512-pnzH6dnFEsR2aa2SJaKb1uSCl3QmIsJ8dEkj0Fky+2AwMMcC9doMqLOQIH6wVTEKaVfKVvLSk5qxPBEZT9mywg==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.12" + }, + "dependencies": { + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "terser-webpack-plugin": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.1.0.tgz", + "integrity": "sha512-sZs43FVvNTqHp5hTkTSIC3XKB7rEC2FCbx9Uv0rM7D4iJsbTA1Q84tiaRYSSKSojBe6LCONX44RF73AEHGasvw==", + "dev": true, + "requires": { + "cacache": "^12.0.3", + "find-cache-dir": "^3.0.0", + "jest-worker": "^24.9.0", + "schema-utils": "^2.2.0", + "serialize-javascript": "^2.1.0", + "source-map": "^0.6.1", + "terser": "^4.3.1", + "webpack-sources": "^1.4.3" + }, + "dependencies": { + "schema-utils": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.2.0.tgz", + "integrity": "sha512-5EwsCNhfFTZvUreQhx/4vVQpJ/lnCAkgoIHLhSpp4ZirE+4hzFvdJi0FMub6hxbFVBJYSpeVVmon+2e7uEGRrA==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "ajv-keywords": "^3.4.1" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "text-encoding": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", @@ -8830,6 +10456,15 @@ "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=" }, + "timers-browserify": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.11.tgz", + "integrity": "sha512-60aV6sgJ5YEbzUdn9c8kYGIqOubPoUdqQCul3SBAsRCZ40s6Y5cMcrW4dt3/k/EsbLVJNl9n6Vz3fTc+k2GeKQ==", + "dev": true, + "requires": { + "setimmediate": "^1.0.4" + } + }, "to-absolute-glob": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", @@ -8840,6 +10475,12 @@ "is-negated-glob": "^1.0.0" } }, + "to-arraybuffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", + "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", + "dev": true + }, "to-buffer": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", @@ -8964,6 +10605,18 @@ "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=", "dev": true }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tty-browserify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "dev": true + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -9039,6 +10692,24 @@ } } }, + "unique-filename": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", + "integrity": "sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==", + "dev": true, + "requires": { + "unique-slug": "^2.0.0" + } + }, + "unique-slug": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz", + "integrity": "sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4" + } + }, "unique-stream": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.2.1.tgz", @@ -9095,23 +10766,65 @@ "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", "dev": true }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "dev": true }, + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", "dev": true }, + "util": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz", + "integrity": "sha512-HShAsny+zS2TZfaXxD9tYj4HQGlBezXZMZuM/S5PKLLoZkShZiGk9o5CzukI1LVHZvjdvZ2Sj1aW/Ndn2NB/HQ==", + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, + "v8-compile-cache": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz", + "integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==", + "dev": true + }, "v8flags": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.1.tgz", @@ -9210,11 +10923,394 @@ } } }, + "vm-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", + "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", + "dev": true + }, "warning-symbol": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/warning-symbol/-/warning-symbol-0.1.0.tgz", "integrity": "sha1-uzHdEbeg+dZ6su2V9Fe2WCW7rSE=" }, + "watchpack": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", + "integrity": "sha512-i6dHe3EyLjMmDlU1/bGQpEw25XSjkJULPuAVKCbNRefQVq48yXKUpwg538F7AZTf9kyr57zj++pQFltUa5H7yA==", + "dev": true, + "requires": { + "chokidar": "^2.0.2", + "graceful-fs": "^4.1.2", + "neo-async": "^2.5.0" + } + }, + "webpack": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.40.2.tgz", + "integrity": "sha512-5nIvteTDCUws2DVvP9Qe+JPla7kWPPIDFZv55To7IycHWZ+Z5qBdaBYPyuXWdhggTufZkQwfIK+5rKQTVovm2A==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.8.5", + "@webassemblyjs/helper-module-context": "1.8.5", + "@webassemblyjs/wasm-edit": "1.8.5", + "@webassemblyjs/wasm-parser": "1.8.5", + "acorn": "^6.2.1", + "ajv": "^6.10.2", + "ajv-keywords": "^3.4.1", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^4.1.0", + "eslint-scope": "^4.0.3", + "json-parse-better-errors": "^1.0.2", + "loader-runner": "^2.4.0", + "loader-utils": "^1.2.3", + "memory-fs": "^0.4.1", + "micromatch": "^3.1.10", + "mkdirp": "^0.5.1", + "neo-async": "^2.6.1", + "node-libs-browser": "^2.2.1", + "schema-utils": "^1.0.0", + "tapable": "^1.1.3", + "terser-webpack-plugin": "^1.4.1", + "watchpack": "^1.6.0", + "webpack-sources": "^1.4.1" + }, + "dependencies": { + "find-cache-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^2.0.0", + "pkg-dir": "^3.0.0" + } + }, + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + } + }, + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "serialize-javascript": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz", + "integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "terser-webpack-plugin": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz", + "integrity": "sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==", + "dev": true, + "requires": { + "cacache": "^12.0.2", + "find-cache-dir": "^2.1.0", + "is-wsl": "^1.1.0", + "schema-utils": "^1.0.0", + "serialize-javascript": "^1.7.0", + "source-map": "^0.6.1", + "terser": "^4.1.2", + "webpack-sources": "^1.4.0", + "worker-farm": "^1.7.0" + } + } + } + }, + "webpack-cli": { + "version": "3.3.9", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.9.tgz", + "integrity": "sha512-xwnSxWl8nZtBl/AFJCOn9pG7s5CYUYdZxmmukv+fAHLcBIHM36dImfpQg3WfShZXeArkWlf6QRw24Klcsv8a5A==", + "dev": true, + "requires": { + "chalk": "2.4.2", + "cross-spawn": "6.0.5", + "enhanced-resolve": "4.1.0", + "findup-sync": "3.0.0", + "global-modules": "2.0.0", + "import-local": "2.0.0", + "interpret": "1.2.0", + "loader-utils": "1.2.3", + "supports-color": "6.1.0", + "v8-compile-cache": "2.0.3", + "yargs": "13.2.4" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "findup-sync": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", + "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" + } + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "global-modules": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz", + "integrity": "sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==", + "dev": true, + "requires": { + "global-prefix": "^3.0.0" + } + }, + "global-prefix": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz", + "integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==", + "dev": true, + "requires": { + "ini": "^1.3.5", + "kind-of": "^6.0.2", + "which": "^1.3.1" + } + }, + "interpret": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", + "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", + "dev": true + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", + "dev": true, + "requires": { + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.2.4", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.4.tgz", + "integrity": "sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.0" + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "webpack-sources": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz", + "integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==", + "dev": true, + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -9270,6 +11366,15 @@ } } }, + "worker-farm": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz", + "integrity": "sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw==", + "dev": true, + "requires": { + "errno": "~0.1.7" + } + }, "wrap-ansi": { "version": "2.1.0", "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", @@ -9296,6 +11401,12 @@ "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", "dev": true }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "dev": true + }, "yargs": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.0.tgz", diff --git a/package.json b/package.json index ebbf316..4e5db05 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A NodeJS library for flashing compiled sketch files to Arduino microcontroller boards.", "bin": "./bin/cli.js", "main": "avrgirl-arduino-node.js", + "module": "dist/avrgirl-arduino.min.js", "scripts": { "test": "gulp test", "cover": "istanbul cover ./tests/*.spec.js && istanbul-coveralls" @@ -54,10 +55,13 @@ "sinon": "^4.1.2", "tap-spec": "^5.0.0", "tape": "^4.2.1", - "virtual-serialport": "^0.3.1" + "terser-webpack-plugin": "^2.1.0", + "virtual-serialport": "^0.3.1", + "webpack": "^4.40.2", + "webpack-cli": "^3.3.9" }, "browser": { "graceful-fs": false, - "serialport": "browser-serialport" + "serialport": false } } diff --git a/tests/demos/arduboy.js b/tests/demos/arduboy.js index 82f22a2..de14cab 100644 --- a/tests/demos/arduboy.js +++ b/tests/demos/arduboy.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'leonardo', debug: true diff --git a/tests/demos/blend-micro.js b/tests/demos/blend-micro.js index 364350d..cb3445f 100644 --- a/tests/demos/blend-micro.js +++ b/tests/demos/blend-micro.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'blend-micro', debug: true diff --git a/tests/demos/circuit-playground-classic.js b/tests/demos/circuit-playground-classic.js index 152e102..52443f7 100644 --- a/tests/demos/circuit-playground-classic.js +++ b/tests/demos/circuit-playground-classic.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'circuit-playground-classic', diff --git a/tests/demos/due168.js b/tests/demos/due168.js index 78ca032..995304a 100644 --- a/tests/demos/due168.js +++ b/tests/demos/due168.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'duemilanove168', debug: true diff --git a/tests/demos/feather.js b/tests/demos/feather.js index b00947b..3b19460 100644 --- a/tests/demos/feather.js +++ b/tests/demos/feather.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'feather', debug: true diff --git a/tests/demos/imuduino.js b/tests/demos/imuduino.js index eee3d2d..cfa1842 100644 --- a/tests/demos/imuduino.js +++ b/tests/demos/imuduino.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'imuduino', debug: true diff --git a/tests/demos/leonardo.js b/tests/demos/leonardo.js index f5a0d88..4e68287 100644 --- a/tests/demos/leonardo.js +++ b/tests/demos/leonardo.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'leonardo', debug: true diff --git a/tests/demos/lilypad-usb.js b/tests/demos/lilypad-usb.js index 80927a7..212c309 100644 --- a/tests/demos/lilypad-usb.js +++ b/tests/demos/lilypad-usb.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'lilypad-usb', debug: true diff --git a/tests/demos/mega.js b/tests/demos/mega.js index 7cc799c..6fbcf41 100644 --- a/tests/demos/mega.js +++ b/tests/demos/mega.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'mega', debug: true diff --git a/tests/demos/micro.js b/tests/demos/micro.js index 89a2bf5..e3327ab 100644 --- a/tests/demos/micro.js +++ b/tests/demos/micro.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var board = { name: 'micro', baud: 57600, diff --git a/tests/demos/nano.js b/tests/demos/nano.js index 2a2e29a..0ee3dce 100644 --- a/tests/demos/nano.js +++ b/tests/demos/nano.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'nano', debug: true diff --git a/tests/demos/pinoccio.js b/tests/demos/pinoccio.js index bc6d579..abf08af 100644 --- a/tests/demos/pinoccio.js +++ b/tests/demos/pinoccio.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'pinoccio', debug: true diff --git a/tests/demos/pro-mini.js b/tests/demos/pro-mini.js index 9721a4b..cf94507 100644 --- a/tests/demos/pro-mini.js +++ b/tests/demos/pro-mini.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'pro-mini', port: '/dev/cu.usbserial-A50285BI', diff --git a/tests/demos/qduino.js b/tests/demos/qduino.js index d4d56c4..2017a4a 100644 --- a/tests/demos/qduino.js +++ b/tests/demos/qduino.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'qduino', debug: true diff --git a/tests/demos/sf-pro-micro.js b/tests/demos/sf-pro-micro.js index d2042b2..81276fb 100644 --- a/tests/demos/sf-pro-micro.js +++ b/tests/demos/sf-pro-micro.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'sf-pro-micro', debug: true diff --git a/tests/demos/tinyduino.js b/tests/demos/tinyduino.js index 5517642..58183c3 100644 --- a/tests/demos/tinyduino.js +++ b/tests/demos/tinyduino.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'tinyduino', debug: true diff --git a/tests/demos/uno.js b/tests/demos/uno.js index 8b565a3..bde46f0 100644 --- a/tests/demos/uno.js +++ b/tests/demos/uno.js @@ -1,4 +1,4 @@ -var Avrgirl = require('../../avrgirl-arduino'); +var Avrgirl = require('../../'); var avrgirl = new Avrgirl({ board: 'uno', diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..64e9859 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,50 @@ +const path = require('path'); +const TerserPlugin = require('terser-webpack-plugin'); + +const importableConfig = { + entry: './avrgirl-arduino-browser.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'avrgirl-arduino.js', + libraryTarget: 'umd' + }, +}; + +const importableMinConfig = { + entry: './avrgirl-arduino-browser.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'avrgirl-arduino.min.js', + libraryTarget: 'umd' + }, + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], + }, +}; + + +const globalConfig = { + entry: './avrgirl-arduino-browser.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'avrgirl-arduino.global.min.js', + library: 'AvrgirlArduino', + libraryTarget: 'window' + }, + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], + }, +}; +const globalConfigNonMin = { + entry: './avrgirl-arduino-browser.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'avrgirl-arduino.global.js', + library: 'AvrgirlArduino', + libraryTarget: 'window' + }, +}; + +module.exports = [importableConfig, importableMinConfig, globalConfig, globalConfigNonMin]; From b42bad96c3f8d6985d3ed88c19d1c3f8df1169c6 Mon Sep 17 00:00:00 2001 From: Suz Hinton Date: Sun, 6 Oct 2019 13:24:30 -0700 Subject: [PATCH 06/94] horrible things to make skt500v2 work with Web Serial --- dist/avrgirl-arduino.global.js | 18587 ++++++++++++++++++++++++++- dist/avrgirl-arduino.global.min.js | 2 +- dist/avrgirl-arduino.js | 2 +- dist/avrgirl-arduino.min.js | 2 +- favicon.ico | 1 + index.html | 2 +- lib/browser-serialport.js | 14 +- lib/stk500v2.js | 2 +- webpack.config.js | 5 +- 9 files changed, 18601 insertions(+), 16 deletions(-) create mode 100644 favicon.ico diff --git a/dist/avrgirl-arduino.global.js b/dist/avrgirl-arduino.global.js index 51808ac..2ca139b 100644 --- a/dist/avrgirl-arduino.global.js +++ b/dist/avrgirl-arduino.global.js @@ -1,22 +1,18595 @@ -window.AvrgirlArduino=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=30)}([function(t,e,n){"use strict";(function(t){ -/*! +window["AvrgirlArduino"] = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 30); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) {/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -var r=n(32),i=n(33),o=n(20);function u(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(u()=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(r)return F(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return O(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){var o,u=1,a=t.length,s=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,a/=2,s/=2,n/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(i){var f=-1;for(o=n;oa&&(n=a-s),o=n;o>=0;o--){for(var l=!0,p=0;pi&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var u=0;u>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function T(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&c)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=t[i+1],u=t[i+2],a=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&a)&&(s=(15&c)<<18|(63&o)<<12|(63&u)<<6|63&a)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=l}return function(t){var e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0),a=Math.min(o,u),c=this.slice(r,i),f=t.slice(e,n),l=0;li)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":return _(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function R(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function I(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function j(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function L(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(t,e,n,r,o){return o||L(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return o||L(t,0,n,8),i.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=this[t],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||M(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=0,u=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=n-1,u=1,a=0;for(this[e+o]=255&t;--o>=0&&(u*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/u>>0)-a&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function q(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(2))},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,c=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?c=s.concat(c):l=-1,c.length&&h())}function h(){if(!f){var t=a(p);f=!0;for(var e=c.length;e;){for(s=c,c=[];++l1)for(var n=1;n1)for(var o=1;o0&&u.length>i&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=u.length,a=s,console&&console.warn&&console.warn(a)}return t}function l(){for(var t=[],e=0;e0&&(u=e[0]),u instanceof Error)throw u;var a=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw a.context=u,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)o(s,this,e);else{var c=s.length,f=g(s,c);for(n=0;n=0;o--)if(n[o]===e||n[o].listener===e){u=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},a.prototype.listeners=function(t){return h(this,t,!0)},a.prototype.rawListeners=function(t){return h(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},a.prototype.listenerCount=d,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(36),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(2))},function(t,e,n){(function(t){function n(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===n(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===n(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===n(t)},e.isError=function(t){return"[object Error]"===n(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,n(0).Buffer)},function(t,e,n){(function(t){var r=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,t,r.depth)}function s(t,e){var n=a.styles[e];return n?"["+a.colors[n][0]+"m"+t+"["+a.colors[n][1]+"m":t}function c(t,e){return t}function f(t,n,r){if(t.customInspect&&n&&E(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=f(t,i,r)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(y(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,n);if(o)return o;var u=Object.keys(n),a=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(n)),S(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return l(n);if(0===u.length){if(E(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(b(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(_(n))return t.stylize(Date.prototype.toString.call(n),"date");if(S(n))return l(n)}var c,w="",x=!1,T=["{","}"];(h(n)&&(x=!0,T=["[","]"]),E(n))&&(w=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(w=" "+RegExp.prototype.toString.call(n)),_(n)&&(w=" "+Date.prototype.toUTCString.call(n)),S(n)&&(w=" "+l(n)),0!==u.length||x&&0!=n.length?r<0?b(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),c=x?function(t,e,n,r,i){for(var o=[],u=0,a=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(c,w,T)):T[0]+w+T[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,n,r,i,o){var u,a,s;if((s=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(a=t.stylize("[Setter]","special")),R(r,i)||(u="["+i+"]"),a||(t.seen.indexOf(s.value)<0?(a=g(n)?f(t,s.value,null):f(t,s.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),m(u)){if(o&&i.match(/^\d+$/))return a;(u=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+a}function h(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return void 0===t}function b(t){return w(t)&&"[object RegExp]"===x(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===x(t)}function S(t){return w(t)&&("[object Error]"===x(t)||t instanceof Error)}function E(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(m(o)&&(o=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!u[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=t.pid;u[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else u[n]=function(){};return u[n]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=d,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=y,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=b,e.isObject=w,e.isDate=_,e.isError=S,e.isFunction=E,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(56);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",k(),e.format.apply(e,arguments))},e.inherits=n(3),e._extend=function(t,e){if(!e||!w(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function P(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(O&&t[O]){var e;if("function"!=typeof(e=t[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,O,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),i=[],o=0;o-1&&t%1==0&&t<=U}function z(t){return null!=t&&N(t.length)&&!function(t){if(!s(t))return!1;var e=D(t);return e==j||e==L||e==I||e==B}(t)}var F={};function q(){}function G(t){return function(){if(null!==t){var e=t;t=null,e.apply(this,arguments)}}}var Y="function"==typeof Symbol&&Symbol.iterator,K=function(t){return Y&&t[Y]&&t[Y]()};function W(t){return null!=t&&"object"==typeof t}var H="[object Arguments]";function V(t){return W(t)&&D(t)==H}var $=Object.prototype,Q=$.hasOwnProperty,J=$.propertyIsEnumerable,Z=V(function(){return arguments}())?V:function(t){return W(t)&&Q.call(t,"callee")&&!J.call(t,"callee")},X=Array.isArray,tt="object"==typeof e&&e&&!e.nodeType&&e,et=tt&&"object"==typeof i&&i&&!i.nodeType&&i,nt=et&&et.exports===tt?E.Buffer:void 0,rt=(nt?nt.isBuffer:void 0)||function(){return!1},it=9007199254740991,ot=/^(?:0|[1-9]\d*)$/;function ut(t,e){return!!(e=null==e?it:e)&&("number"==typeof t||ot.test(t))&&t>-1&&t%1==0&&t2&&(r=o(arguments,1)),e){var c={};Ft(i,(function(t,e){c[e]=t})),c[t]=r,a=!0,s=Object.create(null),n(e,c)}else i[t]=r,d(t)}));u++;var c=b(e[e.length-1]);e.length>1?c(i,r):c(r)}}(t,e)}))}function h(){if(0===c.length&&0===u)return n(null,i);for(;c.length&&u=0&&n.push(r)})),n}Ft(t,(function(e,n){if(!X(e))return p(n,[e]),void f.push(n);var r=e.slice(0,e.length-1),i=r.length;if(0===i)return p(n,e),void f.push(n);l[n]=i,Ut(r,(function(o){if(!t[o])throw new Error("async.auto task `"+n+"` has a non-existent dependency `"+o+"` in "+r.join(", "));var u,a,c;a=function(){0==--i&&p(n,e)},(c=s[u=o])||(c=s[u]=[]),c.push(a)}))})),function(){for(var t,e=0;f.length;)t=f.pop(),e++,Ut(g(t),(function(t){0==--l[t]&&f.push(t)}));if(e!==r)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),h()};function Kt(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n=r?t:function(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=Array(i);++r-1;);return n}(i,o),function(t,e){for(var n=t.length;n--&&Gt(e,t[n],0)>-1;);return n}(i,o)+1).join("")}var pe=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,he=/,/,de=/(=.+)?(\s*)$/,ge=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function ye(t,e){var n={};Ft(t,(function(t,e){var r,i=m(t),o=!i&&1===t.length||i&&0===t.length;if(X(t))r=t.slice(0,-1),t=t[t.length-1],n[e]=r.concat(r.length>0?u:t);else if(o)n[e]=t;else{if(r=function(t){return t=(t=(t=(t=t.toString().replace(ge,"")).match(pe)[2].replace(" ",""))?t.split(he):[]).map((function(t){return le(t.replace(de,""))}))}(t),0===t.length&&!i&&0===r.length)throw new Error("autoInject task functions require explicit parameters.");i||r.pop(),n[e]=r.concat(u)}function u(e,n){var i=Kt(r,(function(t){return e[t]}));i.push(n),b(t).apply(null,i)}})),Yt(n,e)}function ve(){this.head=this.tail=null,this.length=0}function me(t,e){t.length=1,t.head=t.tail=e}function be(t,e,n){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var r=b(t),i=0,o=[],u=!1;function a(t,e,n){if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");if(f.started=!0,X(t)||(t=[t]),0===t.length&&f.idle())return h((function(){f.drain()}));for(var r=0,i=t.length;r0&&o.splice(a,1),u.callback.apply(u,arguments),null!=e&&f.error(e,u.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new ve,concurrency:e,payload:n,saturated:q,unsaturated:q,buffer:e/4,empty:q,drain:q,error:q,started:!1,paused:!1,push:function(t,e){a(t,!1,e)},kill:function(){f.drain=q,f._tasks.empty()},unshift:function(t,e){a(t,!0,e)},remove:function(t){f._tasks.remove(t)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(i=o(arguments,1)),r[e]=i,n(t)}))}),(function(t){n(t,r)}))}function vn(t,e){yn(Ot,t,e)}function mn(t,e,n){yn(xt(e),t,n)}var bn=function(t,e){var n=b(t);return be((function(t,e){n(t[0],e)}),e,1)},wn=function(t,e){var n=bn(t,e);return n.push=function(t,e,r){if(null==r&&(r=q),"function"!=typeof r)throw new Error("task callback must be a function");if(n.started=!0,X(t)||(t=[t]),0===t.length)return h((function(){n.drain()}));e=e||0;for(var i=n._tasks.head;i&&e>=i.priority;)i=i.next;for(var o=0,u=t.length;or?1:0}Mt(t,(function(t,e){r(t,(function(n,r){if(n)return e(n);e(null,{value:t,criteria:r})}))}),(function(t,e){if(t)return n(t);n(null,Kt(e.sort(i),Je("value")))}))}function Bn(t,e,n){var r=b(t);return a((function(i,o){var u,a=!1;i.push((function(){a||(o.apply(null,arguments),clearTimeout(u))})),u=setTimeout((function(){var e=t.name||"anonymous",r=new Error('Callback function "'+e+'" timed out.');r.code="ETIMEDOUT",n&&(r.info=n),a=!0,o(r)}),e),r.apply(null,i)}))}var Un=Math.ceil,Nn=Math.max;function zn(t,e,n,r){var i=b(n);jt(function(t,e,n,r){for(var i=-1,o=Nn(Un((e-t)/(n||1)),0),u=Array(o);o--;)u[r?o:++i]=t,t+=n;return u}(0,t,1),e,i,r)}var Fn=At(zn,1/0),qn=At(zn,1);function Gn(t,e,n,r){arguments.length<=3&&(r=n,n=e,e=X(t)?[]:{}),r=G(r||q);var i=b(n);Ot(t,(function(t,n,r){i(e,t,n,r)}),(function(t){r(t,e)}))}function Yn(t,e){var n,r=null;e=e||q,Ke(t,(function(t,e){b(t)((function(t,i){n=arguments.length>2?o(arguments,1):i,r=t,e(!t)}))}),(function(){e(r,n)}))}function Kn(t){return function(){return(t.unmemoized||t).apply(null,arguments)}}function Wn(t,e,n){n=Et(n||q);var r=b(e);if(!t())return n(null);var i=function(e){if(e)return n(e);if(t())return r(i);var u=o(arguments,1);n.apply(null,[null].concat(u))};r(i)}function Hn(t,e,n){Wn((function(){return!t.apply(this,arguments)}),e,n)}var Vn=function(t,e){if(e=G(e||q),!X(t))return e(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return e();var n=0;function r(e){var r=b(t[n++]);e.push(Et(i)),r.apply(null,e)}function i(i){if(i||n===t.length)return e.apply(null,arguments);r(o(arguments,1))}r([])},$n={apply:u,applyEach:Dt,applyEachSeries:Bt,asyncify:d,auto:Yt,autoInject:ye,cargo:we,compose:xe,concat:ke,concatLimit:Ae,concatSeries:Re,constant:Oe,detect:De,detectLimit:Ie,detectSeries:je,dir:Be,doDuring:Ue,doUntil:ze,doWhilst:Ne,during:Fe,each:Ge,eachLimit:Ye,eachOf:Ot,eachOfLimit:Tt,eachOfSeries:_e,eachSeries:Ke,ensureAsync:We,every:Ve,everyLimit:$e,everySeries:Qe,filter:en,filterLimit:nn,filterSeries:rn,forever:on,groupBy:an,groupByLimit:un,groupBySeries:sn,log:cn,map:Mt,mapLimit:jt,mapSeries:Lt,mapValues:ln,mapValuesLimit:fn,mapValuesSeries:pn,memoize:dn,nextTick:gn,parallel:vn,parallelLimit:mn,priorityQueue:wn,queue:bn,race:_n,reduce:Se,reduceRight:Sn,reflect:En,reflectAll:xn,reject:An,rejectLimit:kn,rejectSeries:Rn,retry:Pn,retryable:Cn,seq:Ee,series:Mn,setImmediate:h,some:Dn,someLimit:In,someSeries:jn,sortBy:Ln,timeout:Bn,times:Fn,timesLimit:zn,timesSeries:qn,transform:Gn,tryEach:Yn,unmemoize:Kn,until:Hn,waterfall:Vn,whilst:Wn,all:Ve,allLimit:$e,allSeries:Qe,any:Dn,anyLimit:In,anySeries:jn,find:De,findLimit:Ie,findSeries:je,forEach:Ge,forEachSeries:Ke,forEachLimit:Ye,forEachOf:Ot,forEachOfSeries:_e,forEachOfLimit:Tt,inject:Se,foldl:Se,foldr:Sn,select:en,selectLimit:nn,selectSeries:rn,wrapSync:d};e.default=$n,e.apply=u,e.applyEach=Dt,e.applyEachSeries=Bt,e.asyncify=d,e.auto=Yt,e.autoInject=ye,e.cargo=we,e.compose=xe,e.concat=ke,e.concatLimit=Ae,e.concatSeries=Re,e.constant=Oe,e.detect=De,e.detectLimit=Ie,e.detectSeries=je,e.dir=Be,e.doDuring=Ue,e.doUntil=ze,e.doWhilst=Ne,e.during=Fe,e.each=Ge,e.eachLimit=Ye,e.eachOf=Ot,e.eachOfLimit=Tt,e.eachOfSeries=_e,e.eachSeries=Ke,e.ensureAsync=We,e.every=Ve,e.everyLimit=$e,e.everySeries=Qe,e.filter=en,e.filterLimit=nn,e.filterSeries=rn,e.forever=on,e.groupBy=an,e.groupByLimit=un,e.groupBySeries=sn,e.log=cn,e.map=Mt,e.mapLimit=jt,e.mapSeries=Lt,e.mapValues=ln,e.mapValuesLimit=fn,e.mapValuesSeries=pn,e.memoize=dn,e.nextTick=gn,e.parallel=vn,e.parallelLimit=mn,e.priorityQueue=wn,e.queue=bn,e.race=_n,e.reduce=Se,e.reduceRight=Sn,e.reflect=En,e.reflectAll=xn,e.reject=An,e.rejectLimit=kn,e.rejectSeries=Rn,e.retry=Pn,e.retryable=Cn,e.seq=Ee,e.series=Mn,e.setImmediate=h,e.some=Dn,e.someLimit=In,e.someSeries=jn,e.sortBy=Ln,e.timeout=Bn,e.times=Fn,e.timesLimit=zn,e.timesSeries=qn,e.transform=Gn,e.tryEach=Yn,e.unmemoize=Kn,e.until=Hn,e.waterfall=Vn,e.whilst=Wn,e.all=Ve,e.allLimit=$e,e.allSeries=Qe,e.any=Dn,e.anyLimit=In,e.anySeries=jn,e.find=De,e.findLimit=Ie,e.findSeries=je,e.forEach=Ge,e.forEachSeries=Ke,e.forEachLimit=Ye,e.forEachOf=Ot,e.forEachOfSeries=_e,e.forEachOfLimit=Tt,e.inject=Se,e.foldl=Se,e.foldr=Sn,e.select=en,e.selectLimit=nn,e.selectSeries=rn,e.wrapSync=d,Object.defineProperty(e,"__esModule",{value:!0})})(e)}).call(this,n(7).setImmediate,n(1),n(2),n(37)(t))},function(t,e,n){(function(e){var r=n(21),i=n(22),o={_parseHex:function(t){try{var n;return n="string"==typeof t?r.readFileSync(t,{encoding:"utf8"}):e.from(t),i.parse(n).data}catch(t){return t}},_hexStringToByte:function(t){return e.from([parseInt(t,16)])}};t.exports=o}).call(this,n(0).Buffer)},function(t,e,n){var r=n(0).Buffer;t.exports=function(t,e){if(r.isBuffer(t)&&r.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var n=0;n-1?r:o.nextTick;m.WritableState=v;var c=n(8);c.inherits=n(3);var f={deprecate:n(67)},l=n(26),p=n(11).Buffer,h=i.Uint8Array||function(){};var d,g=n(27);function y(){}function v(t,e){a=a||n(4),t=t||{};var r=e instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,c=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?(o.nextTick(i,r),o.nextTick(x,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(i(r),t._writableState.errorEmitted=!0,t.emit("error",r),x(t,e))}(t,n,r,e,i);else{var u=S(n);u||n.corked||n.bufferProcessing||!n.bufferedRequest||_(t,n),r?s(w,t,n,u,i):w(t,n,u,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new u(this)}function m(t){if(a=a||n(4),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new v(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function b(t,e,n,r,i,o,u){e.writelen=r,e.writecb=u,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function w(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),x(t,e)}function _(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)i[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;i.allBuffers=s,b(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new u(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,f=n.encoding,l=n.callback;if(b(t,e,!1,e.objectMode?1:c.length,c,f,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function S(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final((function(n){e.pendingcb--,n&&t.emit("error",n),e.prefinished=!0,t.emit("prefinish"),x(t,e)}))}function x(t,e){var n=S(e);return n&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}c.inherits(m,l),v.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(v.prototype,"buffer",{get:f.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof v)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,n){var r,i=this._writableState,u=!1,a=!i.objectMode&&(r=t,p.isBuffer(r)||r instanceof h);return a&&!p.isBuffer(t)&&(t=function(t){return p.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=y),i.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),o.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var i=!0,u=!1;return null===n?u=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||e.objectMode||(u=new TypeError("Invalid non-string/buffer chunk")),u&&(t.emit("error",u),o.nextTick(r,u),i=!1),i}(this,i,t,n))&&(i.pendingcb++,u=function(t,e,n,r,i,o){if(!n){var u=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=p.from(e,n));return e}(e,r,i);r!==u&&(n=!0,i="buffer",r=u)}var a=e.objectMode?1:r.length;e.length+=a;var s=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,x(t,e),n&&(e.finished?o.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=g.destroy,m.prototype._undestroy=g.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,n(1),n(7).setImmediate,n(2))},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){},function(t,e,n){(function(t){e.parse=function(e,n){e instanceof t&&(e=e.toString("ascii"));var r=new t(n||8192),i=0,o=0,u=null,a=null,s=0,c=0;for(;c+11<=e.length;){if(":"!=e.charAt(c++))throw new Error("Line "+(s+1)+" does not start with a colon (:).");s++;var f=parseInt(e.substr(c,2),16);c+=2;var l=parseInt(e.substr(c,4),16);c+=4;var p=parseInt(e.substr(c,2),16);c+=2;var h=e.substr(c,2*f),d=new t(h,"hex");c+=2*f;var g=parseInt(e.substr(c,2),16);c+=2;for(var y=f+(l>>8)+l+p&255,v=0;v=r.length){var b=new t(2*(m+f));r.copy(b,0,0,i),r=b}m>i&&r.fill(255,i,m),d.copy(r,m),i=Math.max(i,m+f);break;case 1:if(0!=f)throw new Error("Invalid EOF record on line "+s+".");return{data:r.slice(0,i),startSegmentAddress:u,startLinearAddress:a};case 2:if(2!=f||0!=l)throw new Error("Invalid extended segment address record on line "+s+".");o=parseInt(h,16)<<4;break;case 3:if(4!=f||0!=l)throw new Error("Invalid start segment address record on line "+s+".");u=parseInt(h,16);break;case 4:if(2!=f||0!=l)throw new Error("Invalid extended linear address record on line "+s+".");o=parseInt(h,16)<<16;break;case 5:if(4!=f||0!=l)throw new Error("Invalid start linear address record on line "+s+".");a=parseInt(h,16);break;default:throw new Error("Invalid record type ("+p+") on line "+s)}"\r"==e.charAt(c)&&c++,"\n"==e.charAt(c)&&c++}throw new Error("Unexpected end of input: missing or invalid EOF record.")}}).call(this,n(0).Buffer)},function(t,e){function n(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}n.keys=function(){return[]},n.resolve=n,t.exports=n,n.id=23},function(t,e){t.exports.MESSAGE_START=27,t.exports.TOKEN=14,t.exports.CMD_SIGN_ON=1,t.exports.CMD_SET_PARAMETER=2,t.exports.CMD_GET_PARAMETER=3,t.exports.CMD_SET_DEVICE_PARAMETERS=4,t.exports.CMD_OSCCAL=5,t.exports.CMD_LOAD_ADDRESS=6,t.exports.CMD_FIRMWARE_UPGRADE=7,t.exports.CMD_ENTER_PROGMODE_ISP=16,t.exports.CMD_LEAVE_PROGMODE_ISP=17,t.exports.CMD_CHIP_ERASE_ISP=18,t.exports.CMD_PROGRAM_FLASH_ISP=19,t.exports.CMD_READ_FLASH_ISP=20,t.exports.CMD_PROGRAM_EEPROM_ISP=21,t.exports.CMD_READ_EEPROM_ISP=22,t.exports.CMD_PROGRAM_FUSE_ISP=23,t.exports.CMD_READ_FUSE_ISP=24,t.exports.CMD_PROGRAM_LOCK_ISP=25,t.exports.CMD_READ_LOCK_ISP=26,t.exports.CMD_READ_SIGNATURE_ISP=27,t.exports.CMD_READ_OSCCAL_ISP=28,t.exports.CMD_SPI_MULTI=29,t.exports.CMD_ENTER_PROGMODE_PP=32,t.exports.CMD_LEAVE_PROGMODE_PP=33,t.exports.CMD_CHIP_ERASE_PP=34,t.exports.CMD_PROGRAM_FLASH_PP=35,t.exports.CMD_READ_FLASH_PP=36,t.exports.CMD_PROGRAM_EEPROM_PP=37,t.exports.CMD_READ_EEPROM_PP=38,t.exports.CMD_PROGRAM_FUSE_PP=39,t.exports.CMD_READ_FUSE_PP=40,t.exports.CMD_PROGRAM_LOCK_PP=41,t.exports.CMD_READ_LOCK_PP=42,t.exports.CMD_READ_SIGNATURE_PP=43,t.exports.CMD_READ_OSCCAL_PP=44,t.exports.CMD_SET_CONTROL_STACK=45,t.exports.CMD_ENTER_PROGMODE_HVSP=48,t.exports.CMD_LEAVE_PROGMODE_HVSP=49,t.exports.CMD_CHIP_ERASE_HVSP=50,t.exports.CMD_PROGRAM_FLASH_HVSP=51,t.exports.CMD_READ_FLASH_HVSP=52,t.exports.CMD_PROGRAM_EEPROM_HVSP=53,t.exports.CMD_READ_EEPROM_HVSP=54,t.exports.CMD_PROGRAM_FUSE_HVSP=55,t.exports.CMD_READ_FUSE_HVSP=56,t.exports.CMD_PROGRAM_LOCK_HVSP=57,t.exports.CMD_READ_LOCK_HVSP=58,t.exports.CMD_READ_SIGNATURE_HVSP=59,t.exports.CMD_READ_OSCCAL_HVSP=60,t.exports.STATUS_CMD_OK=0,t.exports.STATUS_CMD_TOUT=128,t.exports.STATUS_RDY_BSY_TOUT=129,t.exports.STATUS_SET_PARAM_MISSING=130,t.exports.STATUS_CMD_FAILED=192,t.exports.STATUS_CKSUM_ERROR=193,t.exports.STATUS_CMD_UNKNOWN=201,t.exports.STATUS_BUILD_NUMBER_LOW=128,t.exports.STATUS_BUILD_NUMBER_HIGH=129,t.exports.STATUS_HW_VER=144,t.exports.STATUS_SW_MAJOR=145,t.exports.STATUS_SW_MINOR=146,t.exports.STATUS_VTARGET=148,t.exports.STATUS_VADJUST=149,t.exports.STATUS_OSC_PSCALE=150,t.exports.STATUS_OSC_CMATCH=151,t.exports.STATUS_SCK_DURATION=152,t.exports.STATUS_TOPCARD_DETECT=154,t.exports.STATUS_STATUS=156,t.exports.STATUS_DATA=157,t.exports.STATUS_RESET_POLARITY=158,t.exports.STATUS_CONTROLLER_INIT=159,t.exports.ANSWER_CKSUM_ERROR=176},function(t,e,n){"use strict";(function(e,r){var i=n(10);t.exports=b;var o,u=n(20);b.ReadableState=m;n(6).EventEmitter;var a=function(t,e){return t.listeners(e).length},s=n(26),c=n(11).Buffer,f=e.Uint8Array||function(){};var l=n(8);l.inherits=n(3);var p=n(64),h=void 0;h=p&&p.debuglog?p.debuglog("stream"):function(){};var d,g=n(65),y=n(27);l.inherits(b,s);var v=["error","close","destroy","pause","resume"];function m(t,e){t=t||{};var r=e instanceof(o=o||n(4));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,u=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(u||0===u)?u:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=n(28).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function b(t){if(o=o||n(4),!(this instanceof b))return new b(t);this._readableState=new m(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function w(t,e,n,r,i){var o,u=t._readableState;null===e?(u.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,x(t)}(t,u)):(i||(o=function(t,e){var n;r=e,c.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(u,e)),o?t.emit("error",o):u.objectMode||e&&e.length>0?("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r?u.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,u,e,!0):u.ended?t.emit("error",new Error("stream.push() after EOF")):(u.reading=!1,u.decoder&&!n?(e=u.decoder.write(e),u.objectMode||0!==e.length?_(t,u,e,!1):A(t,u)):_(t,u,e,!1))):r||(u.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=S?t=S:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(h("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(T,t):T(t))}function T(t){h("emit readable"),t.emit("readable"),P(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;to.length?o.length:t;if(u===o.length?i+=o:i+=o.slice(0,t),0===(t-=u)){u===o.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(u));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=c.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var o=r.data,u=t>o.length?o.length:t;if(o.copy(n,n.length-t,0,u),0===(t-=u)){u===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(u));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function I(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return h("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):x(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&M(this),null;var r,i=e.needReadable;return h("need readable",i),(0===e.length||e.length-t0?C(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&M(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:b;function c(e,r){h("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,h("cleanup"),t.removeListener("close",v),t.removeListener("finish",m),t.removeListener("drain",l),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",b),n.removeListener("data",g),p=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){h("onend"),t.end()}o.endEmitted?i.nextTick(s):n.once("end",s),t.on("unpipe",c);var l=function(t){return function(){var e=t._readableState;h("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,P(t))}}(n);t.on("drain",l);var p=!1;var d=!1;function g(e){h("ondata"),d=!1,!1!==t.write(e)||d||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==I(o.pipes,t))&&!p&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(e){h("onerror",e),b(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",m),b()}function m(){h("onfinish"),t.removeListener("close",v),b()}function b(){h("unpipe"),n.unpipe(t)}return n.on("data",g),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?u(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",y),t.once("close",v),t.once("finish",m),t.emit("pipe",n),o.flowing||(h("pipe resume"),n.resume()),t},b.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function s(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function f(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function p(t){return t.toString(this.encoding)}function h(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(t.lastNeed=i-1),i;if(--r=0)return i>0&&(t.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,n){"use strict";t.exports=u;var r=n(4),i=n(8);function o(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length0?u-4:u;for(n=0;n>16&255,s[f++]=e>>8&255,s[f++]=255&e;2===a&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,s[f++]=255&e);1===a&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,s[f++]=e>>8&255,s[f++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],u=0,a=n-i;ua?a:u+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=u.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t,e,n){for(var i,o,u=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return u.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,i){var o,u,a=8*i-r-1,s=(1<>1,f=-7,l=n?i-1:0,p=n?-1:1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=p,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=r;f>0;u=256*u+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===s)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),o-=c}return(h?-1:1)*u*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var u,a,s,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=f):(u=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-u))<1&&(u--,s*=2),(e+=u+l>=1?p/s:p*Math.pow(2,1-l))*s>=2&&(u++,s/=2),u+l>=f?(a=0,u=f):u+l>=1?(a=(e*s-1)*Math.pow(2,i),u+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),u=0));i>=8;t[n+h]=255&a,h+=d,a/=256,i-=8);for(u=u<0;t[n+h]=255&u,h+=d,u/=256,c-=8);t[n+h-d]|=128*g}},function(t,e,n){var r=n(35),i=n(12),o=n(38),u=(n(13),function(t){this.options=t,this.debug=this.options.debug?console.log.bind(console):function(){},this.board=this.options.board});u.prototype._init=function(t){this._setUpSerial((function(e){return t(e)}))},u.prototype._setUpSerial=function(t){return this.serialPort=new r("",{baudRate:this.board.baud,autoOpen:!1}),t(null)},u.prototype._sniffPort=function(t){var e=this.board.productId.map((function(t){return parseInt(t,16)}));this._listPorts((function(n,r){var i=r.filter((function(t){return-1!==e.indexOf(parseInt(t._standardPid,16))}));return t(null,i)}))},u.prototype._setDTR=function(t,e,n){var r={rts:t,dtr:t};this.serialPort.set(r,(function(t){if(t)return n(t);setTimeout((function(){n(t)}),e)}))},u.prototype._pollForPort=function(t){var e=this,n=o((function(t){var n=!1;e._sniffPort((function(r,i){i.length&&(e.options.port=i[0].comName,n=!0),t(n)}))}));n.every(100).ask(15),n((function(n){if(!n)return t(new Error("could not reconnect after resetting board."));e.debug("found port on",e.options.port),e._setUpSerial((function(e){return t(e)}))}))},u.prototype._pollForOpen=function(t){var e=this,n=o((function(t){e.serialPort.open((function(e){t(!e)}))}));n.every(200).ask(10),n((function(n){var r;n||(r=new Error("could not open board on "+e.serialPort.path)),t(r)}))},u.prototype._cycleDTR=function(t){i.series([this._setDTR.bind(this,!0,250),this._setDTR.bind(this,!1,50)],(function(e){return t(e)}))},u.prototype._listPorts=function(t){var e=[];r.list((function(n,r){if(n)return t(n);for(var i=0;it(null,e)).catch(e=>t(e))}open(t){navigator.serial.requestPort(this.requestOptions).then(t=>(this.port=t,this.port.open({baudrate:this.baudrate||57600}))).then(()=>this.writer=this.port.writable.getWriter()).then(()=>this.reader=this.port.readable.getReader()).then(async()=>{for(this.emit("open"),t(null);this.port.readable;)try{for(;;){const{value:t,done:n}=await this.reader.read();if(n)break;this.emit("data",e.from(t))}}catch(t){console.log("ERROR while reading port:",t)}}).catch(e=>{t(e)})}close(t){if(this.port.close(),t)return t(null)}set(t,e){this.port.setSignals(t).then(()=>e(null)).catch(t=>e(t))}write(t,e){return this.writer.write(t),e(null)}read(t){this.reader.read().then(e=>t(null,e)).catch(e=>t(e))}flush(){this.port.flush()}}}).call(this,n(0).Buffer)},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,u,a,s=1,c={},f=!1,l=t.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(t);p=p&&p.setTimeout?p:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){o.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(t){var e=l.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(u="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(u)&&d(+e.data.slice(u.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),r=function(e){t.postMessage(u+e,"*")}),p.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=o?n&&(n=null,r(!!t)):(u&&(!0===u?e=i(e,c):e+=c*u),s=setTimeout(f,e))}return(e=function(t){if(s&&(clearTimeout(s),s=null,n&&n(!1),n=null,c=0),arguments.length){if(!r(t,"function"))throw new TypeError("done callback must be a function");n=t}s=setTimeout(f,a)}).ask=function(t){if(s)throw new SyntaxError("can not set ask limit during polling");if(!r(t,"number"))throw new TypeError("ask limit must be a number");return o=t,e},e.every=function(t){if(s)throw new SyntaxError("can not set timeout during polling");if(!r(t,"number"))throw new TypeError("timout must be a number");return a=t,e},e.incr=function(t){if(s)throw new SyntexError("can not set increment during polling");if(!arguments.length||r(t,"boolean"))u=!!t;else{if(!r(t,"number"))throw new TypeError("increment must be a boolean or number");u=t}return e},e}()}},function(t,e){t.exports=function(t,e){function n(e){return"object"==typeof t&&null!==t}function r(t){return t.name.toLowerCase()}switch(2===arguments.length&&void 0===e?e="undefined":Number.isNaN(e)&&(e="NaN"),e){case"boolean":case"function":case"string":return typeof t===e;case"number":return typeof t===e&&!isNaN(t);case Number:if(isNaN(t))return!1;case String:case Boolean:return typeof t===r(e);case Object:case"object":return n();case"array":return Array.isArray(t);case"regex":case"regexp":return t instanceof RegExp;case"date":return t instanceof Date;case"null":case null:return null===t;case"undefined":return void 0===t;case"NaN":return Number.isNaN(t);case"arguments":return!!n()&&("function"==typeof t.callee||/arguments/i.test(t.toString()));default:return"function"==typeof e?t instanceof e:t}}},function(t,e){t.exports=function(t,e){for(var n=0;n++>8&255,c={cmd:[i.Cmnd_STK_LOAD_ADDRESS,a,s],responseData:i.OK_RESPONSE,timeout:n};o(t,c,(function(t,e){u.log("loaded address",t,e),r(t,e)}))},u.prototype.loadPage=function(t,n,r,u){this.log("load page");var a=this,s=255&n.length,c=n.length>>8,f={cmd:e.concat([new e([i.Cmnd_STK_PROG_PAGE,c,s,70]),n,new e([i.Sync_CRC_EOP])]),responseData:i.OK_RESPONSE,timeout:r};o(t,f,(function(t,e){a.log("loaded page",t,e),u(t,e)}))},u.prototype.upload=function(t,e,n,i,o){this.log("program");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.loadPage(t,u,i,e)},function(t){c.log("programmed page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("page done"),o(t)}))}),(function(t){c.log("upload done"),o(t)}))},u.prototype.exitProgrammingMode=function(t,e,n){this.log("send leave programming mode");var r=this,u={cmd:[i.Cmnd_STK_LEAVE_PROGMODE],responseData:i.OK_RESPONSE,timeout:e};o(t,u,(function(t,e){r.log("sent leave programming mode",t,e),n(t,e)}))},u.prototype.verify=function(t,e,n,i,o){this.log("verify");var u,a,s=0,c=this;r.whilst((function(){return s>1,t()},function(e){c.loadAddress(t,a,i,e)},function(t){u=e.slice(s,e.length>n?s+n:e.length-1),t()},function(e){c.verifyPage(t,u,n,i,e)},function(t){c.log("verified page"),s+=u.length,setTimeout(t,4)}],(function(t){c.log("verify done"),o(t)}))}),(function(t){c.log("verify done"),o(t)}))},u.prototype.verifyPage=function(t,n,r,u,a){this.log("verify page");var s=this;match=e.concat([new e([i.Resp_STK_INSYNC]),n,new e([i.Resp_STK_OK])]);var c=n.length>=r?r:n.length,f={cmd:[i.Cmnd_STK_READ_PAGE,c>>8&255,255&c,70],responseLength:match.length,timeout:u};o(t,f,(function(t,e){s.log("confirm page",t,e,e.toString("hex")),a(t,e)}))},u.prototype.bootload=function(t,e,n,i){var o={pagesizehigh:n.pagesizehigh<<8&255,pagesizelow:255&n.pagesizelow};r.series([this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.sync.bind(this,t,3,n.timeout),this.verifySignature.bind(this,t,n.signature,n.timeout),this.setOptions.bind(this,t,o,n.timeout),this.enterProgrammingMode.bind(this,t,n.timeout),this.upload.bind(this,t,e,n.pageSize,n.timeout),this.verify.bind(this,t,e,n.pageSize,n.timeout),this.exitProgrammingMode.bind(this,t,n.timeout)],(function(t){return i(t)}))},t.exports=u}).call(this,n(0).Buffer)},function(t,e,n){(function(n,r){var i; -/*! +/* eslint-disable no-proto */ + + + +var base64 = __webpack_require__(32) +var ieee754 = __webpack_require__(33) +var isArray = __webpack_require__(20) + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +/* + * Export kMaxLength after typed array support is determined. + */ +exports.kMaxLength = kMaxLength() + +function typedArraySupport () { + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +} + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr +} + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +} + +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) + } + return that +} + +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start] + } + } + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = (value & 0xff) + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) + var len = bytes.length + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(2))) + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || new Function("return this")(); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + + + +/**/ + +var pna = __webpack_require__(10); +/**/ + +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var util = __webpack_require__(8); +util.inherits = __webpack_require__(3); +/**/ + +var Readable = __webpack_require__(25); +var Writable = __webpack_require__(19); + +util.inherits(Duplex, Readable); + +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + pna.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + pna.nextTick(cb, err); +}; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +/* + +The MIT License (MIT) + +Original Library + - Copyright (c) Marak Squires + +Additional functionality + - Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +var colors = {}; +module['exports'] = colors; + +colors.themes = {}; + +var ansiStyles = colors.styles = __webpack_require__(47); +var defineProps = Object.defineProperties; + +colors.supportsColor = __webpack_require__(48); + +if (typeof colors.enabled === "undefined") { + colors.enabled = colors.supportsColor; +} + +colors.stripColors = colors.strip = function(str){ + return ("" + str).replace(/\x1B\[\d+m/g, ''); +}; + + +var stylize = colors.stylize = function stylize (str, style) { + if (!colors.enabled) { + return str+''; + } + + return ansiStyles[style].open + str + ansiStyles[style].close; +} + +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; +var escapeStringRegexp = function (str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + return str.replace(matchOperatorsRe, '\\$&'); +} + +function build(_styles) { + var builder = function builder() { + return applyStyle.apply(builder, arguments); + }; + builder._styles = _styles; + // __proto__ is used because we must return a function, but there is + // no way to create a function with a different prototype. + builder.__proto__ = proto; + return builder; +} + +var styles = (function () { + var ret = {}; + ansiStyles.grey = ansiStyles.gray; + Object.keys(ansiStyles).forEach(function (key) { + ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); + ret[key] = { + get: function () { + return build(this._styles.concat(key)); + } + }; + }); + return ret; +})(); + +var proto = defineProps(function colors() {}, styles); + +function applyStyle() { + var args = arguments; + var argsLen = args.length; + var str = argsLen !== 0 && String(arguments[0]); + if (argsLen > 1) { + for (var a = 1; a < argsLen; a++) { + str += ' ' + args[a]; + } + } + + if (!colors.enabled || !str) { + return str; + } + + var nestedStyles = this._styles; + + var i = nestedStyles.length; + while (i--) { + var code = ansiStyles[nestedStyles[i]]; + str = code.open + str.replace(code.closeRe, code.open) + code.close; + } + + return str; +} + +function applyTheme (theme) { + for (var style in theme) { + (function(style){ + colors[style] = function(str){ + if (typeof theme[style] === 'object'){ + var out = str; + for (var i in theme[style]){ + out = colors[theme[style][i]](out); + } + return out; + } + return colors[theme[style]](str); + }; + })(style) + } +} + +colors.setTheme = function (theme) { + if (typeof theme === 'string') { + try { + colors.themes[theme] = __webpack_require__(23)(theme); + applyTheme(colors.themes[theme]); + return colors.themes[theme]; + } catch (err) { + console.log(err); + return err; + } + } else { + applyTheme(theme); + } +}; + +function init() { + var ret = {}; + Object.keys(styles).forEach(function (name) { + ret[name] = { + get: function () { + return build([name]); + } + }; + }); + return ret; +} + +var sequencer = function sequencer (map, str) { + var exploded = str.split(""), i = 0; + exploded = exploded.map(map); + return exploded.join(""); +}; + +// custom formatter methods +colors.trap = __webpack_require__(49); +colors.zalgo = __webpack_require__(50); + +// maps +colors.maps = {}; +colors.maps.america = __webpack_require__(51); +colors.maps.zebra = __webpack_require__(52); +colors.maps.rainbow = __webpack_require__(53); +colors.maps.random = __webpack_require__(54) + +for (var map in colors.maps) { + (function(map){ + colors[map] = function (str) { + return sequencer(colors.maps[map], str); + } + })(map) +} + +defineProps(colors, init()); + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +var R = typeof Reflect === 'object' ? Reflect : null +var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + +var ReflectOwnKeys +if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; +} + +function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); +} + +var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; +} + +function EventEmitter() { + EventEmitter.init.call(this); +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +var defaultMaxListeners = 10; + +Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); + } + defaultMaxListeners = arg; + } +}); + +EventEmitter.init = function() { + + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; +}; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; +}; + +function $getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} + +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return $getMaxListeners(this); +}; + +EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); + + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event + } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } + + var handler = events[type]; + + if (handler === undefined) + return false; + + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } + + return true; +}; + +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + + // Check for listener leak + m = $getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } + } + + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + +function onceWrapper() { + var args = []; + for (var i = 0; i < arguments.length; i++) args.push(arguments[i]); + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + ReflectApply(this.listener, this.target, args); + } +} + +function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} + +EventEmitter.prototype.once = function once(type, listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// Emits a 'removeListener' event if and only if the listener was removed. +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; + + events = this._events; + if (events === undefined) + return this; + + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } + + return this; + }; + +function _listeners(target, type, unwrap) { + var events = target._events; + + if (events === undefined) + return []; + + var evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} + +EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); +}; + +EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); +}; + +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } +}; + +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } + } + + return 0; +} + +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; + +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; +} + +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} + +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) || + (typeof self !== "undefined" && self) || + window; +var apply = Function.prototype.apply; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, scope, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { + if (timeout) { + timeout.close(); + } +}; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(scope, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// setimmediate attaches itself to the global object +__webpack_require__(36); +// On some exotic environments, it's not clear which object `setimmediate` was +// able to install onto. Search each possibility in the same order as the +// `setimmediate` library. +exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) || + (typeof global !== "undefined" && global.setImmediate) || + (this && this.setImmediate); +exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || + (typeof global !== "undefined" && global.clearImmediate) || + (this && this.clearImmediate); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(2))) + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(0).Buffer)) + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || + function getOwnPropertyDescriptors(obj) { + var keys = Object.keys(obj); + var descriptors = {}; + for (var i = 0; i < keys.length; i++) { + descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]); + } + return descriptors; + }; + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + if (typeof process !== 'undefined' && process.noDeprecation === true) { + return fn; + } + + // Allow for deprecating things in the process of starting up. + if (typeof process === 'undefined') { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; + + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = __webpack_require__(56); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = __webpack_require__(3); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined; + +exports.promisify = function promisify(original) { + if (typeof original !== 'function') + throw new TypeError('The "original" argument must be of type Function'); + + if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { + var fn = original[kCustomPromisifiedSymbol]; + if (typeof fn !== 'function') { + throw new TypeError('The "util.promisify.custom" argument must be of type Function'); + } + Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, enumerable: false, writable: false, configurable: true + }); + return fn; + } + + function fn() { + var promiseResolve, promiseReject; + var promise = new Promise(function (resolve, reject) { + promiseResolve = resolve; + promiseReject = reject; + }); + + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + args.push(function (err, value) { + if (err) { + promiseReject(err); + } else { + promiseResolve(value); + } + }); + + try { + original.apply(this, args); + } catch (err) { + promiseReject(err); + } + + return promise; + } + + Object.setPrototypeOf(fn, Object.getPrototypeOf(original)); + + if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, enumerable: false, writable: false, configurable: true + }); + return Object.defineProperties( + fn, + getOwnPropertyDescriptors(original) + ); +} + +exports.promisify.custom = kCustomPromisifiedSymbol + +function callbackifyOnRejected(reason, cb) { + // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M). + // Because `null` is a special error value in callbacks which means "no error + // occurred", we error-wrap so the callback consumer can distinguish between + // "the promise rejected with null" or "the promise fulfilled with undefined". + if (!reason) { + var newReason = new Error('Promise was rejected with a falsy value'); + newReason.reason = reason; + reason = newReason; + } + return cb(reason); +} + +function callbackify(original) { + if (typeof original !== 'function') { + throw new TypeError('The "original" argument must be of type Function'); + } + + // We DO NOT return the promise as it gives the user a false sense that + // the promise is actually somehow related to the callback's execution + // and that the callback throwing will reject the promise. + function callbackified() { + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + + var maybeCb = args.pop(); + if (typeof maybeCb !== 'function') { + throw new TypeError('The last argument must be of type Function'); + } + var self = this; + var cb = function() { + return maybeCb.apply(self, arguments); + }; + // In true node style we process the callback on `nextTick` with all the + // implications (stack, `uncaughtException`, `async_hooks`) + original.apply(this, args) + .then(function(ret) { process.nextTick(cb, null, ret) }, + function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) }); + } + + Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)); + Object.defineProperties(callbackified, + getOwnPropertyDescriptors(original)); + return callbackified; +} +exports.callbackify = callbackify; + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1))) + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process) { + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} + + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1))) + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +/* eslint-disable node/no-deprecated-api */ +var buffer = __webpack_require__(0) +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(setImmediate, process, global, module) {(function (global, factory) { + true ? factory(exports) : + undefined; +}(this, (function (exports) { 'use strict'; + +function slice(arrayLike, start) { + start = start|0; + var newLen = Math.max(arrayLike.length - start, 0); + var newArr = Array(newLen); + for(var idx = 0; idx < newLen; idx++) { + newArr[idx] = arrayLike[start + idx]; + } + return newArr; +} + +/** + * Creates a continuation function with some arguments already applied. + * + * Useful as a shorthand when combined with other control flow functions. Any + * arguments passed to the returned function are added to the arguments + * originally passed to apply. + * + * @name apply + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {Function} fn - The function you want to eventually apply all + * arguments to. Invokes with (arguments...). + * @param {...*} arguments... - Any number of arguments to automatically apply + * when the continuation is called. + * @returns {Function} the partially-applied function + * @example + * + * // using apply + * async.parallel([ + * async.apply(fs.writeFile, 'testfile1', 'test1'), + * async.apply(fs.writeFile, 'testfile2', 'test2') + * ]); + * + * + * // the same process without using apply + * async.parallel([ + * function(callback) { + * fs.writeFile('testfile1', 'test1', callback); + * }, + * function(callback) { + * fs.writeFile('testfile2', 'test2', callback); + * } + * ]); + * + * // It's possible to pass any number of additional arguments when calling the + * // continuation: + * + * node> var fn = async.apply(sys.puts, 'one'); + * node> fn('two', 'three'); + * one + * two + * three + */ +var apply = function(fn/*, ...args*/) { + var args = slice(arguments, 1); + return function(/*callArgs*/) { + var callArgs = slice(arguments); + return fn.apply(null, args.concat(callArgs)); + }; +}; + +var initialParams = function (fn) { + return function (/*...args, callback*/) { + var args = slice(arguments); + var callback = args.pop(); + fn.call(this, args, callback); + }; +}; + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; +var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; + +function fallback(fn) { + setTimeout(fn, 0); +} + +function wrap(defer) { + return function (fn/*, ...args*/) { + var args = slice(arguments, 1); + defer(function () { + fn.apply(null, args); + }); + }; +} + +var _defer; + +if (hasSetImmediate) { + _defer = setImmediate; +} else if (hasNextTick) { + _defer = process.nextTick; +} else { + _defer = fallback; +} + +var setImmediate$1 = wrap(_defer); + +/** + * Take a sync function and make it async, passing its return value to a + * callback. This is useful for plugging sync functions into a waterfall, + * series, or other async functions. Any arguments passed to the generated + * function will be passed to the wrapped function (except for the final + * callback argument). Errors thrown will be passed to the callback. + * + * If the function passed to `asyncify` returns a Promise, that promises's + * resolved/rejected state will be used to call the callback, rather than simply + * the synchronous return value. + * + * This also means you can asyncify ES2017 `async` functions. + * + * @name asyncify + * @static + * @memberOf module:Utils + * @method + * @alias wrapSync + * @category Util + * @param {Function} func - The synchronous function, or Promise-returning + * function to convert to an {@link AsyncFunction}. + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be + * invoked with `(args..., callback)`. + * @example + * + * // passing a regular synchronous function + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(JSON.parse), + * function (data, next) { + * // data is the result of parsing the text. + * // If there was a parsing error, it would have been caught. + * } + * ], callback); + * + * // passing a function returning a promise + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(function (contents) { + * return db.model.create(contents); + * }), + * function (model, next) { + * // `model` is the instantiated model object. + * // If there was an error, this function would be skipped. + * } + * ], callback); + * + * // es2017 example, though `asyncify` is not needed if your JS environment + * // supports async functions out of the box + * var q = async.queue(async.asyncify(async function(file) { + * var intermediateStep = await processFile(file); + * return await somePromise(intermediateStep) + * })); + * + * q.push(files); + */ +function asyncify(func) { + return initialParams(function (args, callback) { + var result; + try { + result = func.apply(this, args); + } catch (e) { + return callback(e); + } + // if result is Promise object + if (isObject(result) && typeof result.then === 'function') { + result.then(function(value) { + invokeCallback(callback, null, value); + }, function(err) { + invokeCallback(callback, err.message ? err : new Error(err)); + }); + } else { + callback(null, result); + } + }); +} + +function invokeCallback(callback, error, value) { + try { + callback(error, value); + } catch (e) { + setImmediate$1(rethrow, e); + } +} + +function rethrow(error) { + throw error; +} + +var supportsSymbol = typeof Symbol === 'function'; + +function isAsync(fn) { + return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction'; +} + +function wrapAsync(asyncFn) { + return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn; +} + +function applyEach$1(eachfn) { + return function(fns/*, ...args*/) { + var args = slice(arguments, 1); + var go = initialParams(function(args, callback) { + var that = this; + return eachfn(fns, function (fn, cb) { + wrapAsync(fn).apply(that, args.concat(cb)); + }, callback); + }); + if (args.length) { + return go.apply(this, args); + } + else { + return go; + } + }; +} + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** Built-in value references. */ +var Symbol$1 = root.Symbol; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$1.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString$1.call(value); +} + +/** `Object#toString` result references. */ +var nullTag = '[object Null]'; +var undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]'; +var funcTag = '[object Function]'; +var genTag = '[object GeneratorFunction]'; +var proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); +} + +// A temporary value used to identify if the loop should be broken. +// See #1064, #1293 +var breakLoop = {}; + +/** + * This method returns `undefined`. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example + * + * _.times(2, _.noop); + * // => [undefined, undefined] + */ +function noop() { + // No operation performed. +} + +function once(fn) { + return function () { + if (fn === null) return; + var callFn = fn; + fn = null; + callFn.apply(this, arguments); + }; +} + +var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; + +var getIterator = function (coll) { + return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol](); +}; + +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]'; + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; +} + +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$3.hasOwnProperty; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto$3.propertyIsEnumerable; + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); +}; + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +/** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ +function stubFalse() { + return false; +} + +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Built-in value references. */ +var Buffer = moduleExports ? root.Buffer : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; + +/** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$1 = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER$1 : length; + return !!length && + (typeof value == 'number' || reIsUint.test(value)) && + (value > -1 && value % 1 == 0 && value < length); +} + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]'; +var arrayTag = '[object Array]'; +var boolTag = '[object Boolean]'; +var dateTag = '[object Date]'; +var errorTag = '[object Error]'; +var funcTag$1 = '[object Function]'; +var mapTag = '[object Map]'; +var numberTag = '[object Number]'; +var objectTag = '[object Object]'; +var regexpTag = '[object RegExp]'; +var setTag = '[object Set]'; +var stringTag = '[object String]'; +var weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]'; +var dataViewTag = '[object DataView]'; +var float32Tag = '[object Float32Array]'; +var float64Tag = '[object Float64Array]'; +var int8Tag = '[object Int8Array]'; +var int16Tag = '[object Int16Array]'; +var int32Tag = '[object Int32Array]'; +var uint8Tag = '[object Uint8Array]'; +var uint8ClampedTag = '[object Uint8ClampedArray]'; +var uint16Tag = '[object Uint16Array]'; +var uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag$1] = +typedArrayTags[mapTag] = typedArrayTags[numberTag] = +typedArrayTags[objectTag] = typedArrayTags[regexpTag] = +typedArrayTags[setTag] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag] = false; + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +} + +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; +} + +/** Detect free variable `exports`. */ +var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; + +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports$1 && freeGlobal.process; + +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$2.hasOwnProperty; + +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty$1.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$5 = Object.prototype; + +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5; + + return value === proto; +} + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = overArg(Object.keys, Object); + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$4.hasOwnProperty; + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty$3.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +function createArrayIterator(coll) { + var i = -1; + var len = coll.length; + return function next() { + return ++i < len ? {value: coll[i], key: i} : null; + } +} + +function createES2015Iterator(iterator) { + var i = -1; + return function next() { + var item = iterator.next(); + if (item.done) + return null; + i++; + return {value: item.value, key: i}; + } +} + +function createObjectIterator(obj) { + var okeys = keys(obj); + var i = -1; + var len = okeys.length; + return function next() { + var key = okeys[++i]; + return i < len ? {value: obj[key], key: key} : null; + }; +} + +function iterator(coll) { + if (isArrayLike(coll)) { + return createArrayIterator(coll); + } + + var iterator = getIterator(coll); + return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); +} + +function onlyOnce(fn) { + return function() { + if (fn === null) throw new Error("Callback was already called."); + var callFn = fn; + fn = null; + callFn.apply(this, arguments); + }; +} + +function _eachOfLimit(limit) { + return function (obj, iteratee, callback) { + callback = once(callback || noop); + if (limit <= 0 || !obj) { + return callback(null); + } + var nextElem = iterator(obj); + var done = false; + var running = 0; + + function iterateeCallback(err, value) { + running -= 1; + if (err) { + done = true; + callback(err); + } + else if (value === breakLoop || (done && running <= 0)) { + done = true; + return callback(null); + } + else { + replenish(); + } + } + + function replenish () { + while (running < limit && !done) { + var elem = nextElem(); + if (elem === null) { + done = true; + if (running <= 0) { + callback(null); + } + return; + } + running += 1; + iteratee(elem.value, elem.key, onlyOnce(iterateeCallback)); + } + } + + replenish(); + }; +} + +/** + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a + * time. + * + * @name eachOfLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.eachOf]{@link module:Collections.eachOf} + * @alias forEachOfLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. The `key` is the item's key, or index in the case of an + * array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + */ +function eachOfLimit(coll, limit, iteratee, callback) { + _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback); +} + +function doLimit(fn, limit) { + return function (iterable, iteratee, callback) { + return fn(iterable, limit, iteratee, callback); + }; +} + +// eachOf implementation optimized for array-likes +function eachOfArrayLike(coll, iteratee, callback) { + callback = once(callback || noop); + var index = 0, + completed = 0, + length = coll.length; + if (length === 0) { + callback(null); + } + + function iteratorCallback(err, value) { + if (err) { + callback(err); + } else if ((++completed === length) || value === breakLoop) { + callback(null); + } + } + + for (; index < length; index++) { + iteratee(coll[index], index, onlyOnce(iteratorCallback)); + } +} + +// a generic version of eachOf which can handle array, object, and iterator cases. +var eachOfGeneric = doLimit(eachOfLimit, Infinity); + +/** + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument + * to the iteratee. + * + * @name eachOf + * @static + * @memberOf module:Collections + * @method + * @alias forEachOf + * @category Collection + * @see [async.each]{@link module:Collections.each} + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each + * item in `coll`. + * The `key` is the item's key, or index in the case of an array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @example + * + * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; + * var configs = {}; + * + * async.forEachOf(obj, function (value, key, callback) { + * fs.readFile(__dirname + value, "utf8", function (err, data) { + * if (err) return callback(err); + * try { + * configs[key] = JSON.parse(data); + * } catch (e) { + * return callback(e); + * } + * callback(); + * }); + * }, function (err) { + * if (err) console.error(err.message); + * // configs is now a map of JSON data + * doSomethingWith(configs); + * }); + */ +var eachOf = function(coll, iteratee, callback) { + var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; + eachOfImplementation(coll, wrapAsync(iteratee), callback); +}; + +function doParallel(fn) { + return function (obj, iteratee, callback) { + return fn(eachOf, obj, wrapAsync(iteratee), callback); + }; +} + +function _asyncMap(eachfn, arr, iteratee, callback) { + callback = callback || noop; + arr = arr || []; + var results = []; + var counter = 0; + var _iteratee = wrapAsync(iteratee); + + eachfn(arr, function (value, _, callback) { + var index = counter++; + _iteratee(value, function (err, v) { + results[index] = v; + callback(err); + }); + }, function (err) { + callback(err, results); + }); +} + +/** + * Produces a new collection of values by mapping each value in `coll` through + * the `iteratee` function. The `iteratee` is called with an item from `coll` + * and a callback for when it has finished processing. Each of these callback + * takes 2 arguments: an `error`, and the transformed item from `coll`. If + * `iteratee` passes an error to its callback, the main `callback` (for the + * `map` function) is immediately called with the error. + * + * Note, that since this function applies the `iteratee` to each item in + * parallel, there is no guarantee that the `iteratee` functions will complete + * in order. However, the results array will be in the same order as the + * original `coll`. + * + * If `map` is passed an Object, the results will be an Array. The results + * will roughly be in the order of the original Objects' keys (but this can + * vary across JavaScript engines). + * + * @name map + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an Array of the + * transformed items from the `coll`. Invoked with (err, results). + * @example + * + * async.map(['file1','file2','file3'], fs.stat, function(err, results) { + * // results is now an array of stats for each file + * }); + */ +var map = doParallel(_asyncMap); + +/** + * Applies the provided arguments to each function in the array, calling + * `callback` after all functions have completed. If you only provide the first + * argument, `fns`, then it will return a function which lets you pass in the + * arguments as if it were a single function call. If more arguments are + * provided, `callback` is required while `args` is still optional. + * + * @name applyEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s + * to all call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {Function} - If only the first argument, `fns`, is provided, it will + * return a function which lets you pass in the arguments as if it were a single + * function call. The signature is `(..args, callback)`. If invoked with any + * arguments, `callback` is required. + * @example + * + * async.applyEach([enableSearch, updateSchema], 'bucket', callback); + * + * // partial application example: + * async.each( + * buckets, + * async.applyEach([enableSearch, updateSchema]), + * callback + * ); + */ +var applyEach = applyEach$1(map); + +function doParallelLimit(fn) { + return function (obj, limit, iteratee, callback) { + return fn(_eachOfLimit(limit), obj, wrapAsync(iteratee), callback); + }; +} + +/** + * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. + * + * @name mapLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + */ +var mapLimit = doParallelLimit(_asyncMap); + +/** + * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time. + * + * @name mapSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + */ +var mapSeries = doLimit(mapLimit, 1); + +/** + * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time. + * + * @name applyEachSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.applyEach]{@link module:ControlFlow.applyEach} + * @category Control Flow + * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s to all + * call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {Function} - If only the first argument is provided, it will return + * a function which lets you pass in the arguments as if it were a single + * function call. + */ +var applyEachSeries = applyEach$1(mapSeries); + +/** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ +function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; +} + +/** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; + + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; +} + +/** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); + +/** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); +} + +/** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); + + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ +function baseIsNaN(value) { + return value !== value; +} + +/** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); +} + +/** + * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on + * their requirements. Each function can optionally depend on other functions + * being completed first, and each function is run as soon as its requirements + * are satisfied. + * + * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence + * will stop. Further tasks will not execute (so any other functions depending + * on it will not run), and the main `callback` is immediately called with the + * error. + * + * {@link AsyncFunction}s also receive an object containing the results of functions which + * have completed so far as the first argument, if they have dependencies. If a + * task function has no dependencies, it will only be passed a callback. + * + * @name auto + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Object} tasks - An object. Each of its properties is either a + * function or an array of requirements, with the {@link AsyncFunction} itself the last item + * in the array. The object's key of a property serves as the name of the task + * defined by that property, i.e. can be used when specifying requirements for + * other tasks. The function receives one or two arguments: + * * a `results` object, containing the results of the previously executed + * functions, only passed if the task has any dependencies, + * * a `callback(err, result)` function, which must be called when finished, + * passing an `error` (which can be `null`) and the result of the function's + * execution. + * @param {number} [concurrency=Infinity] - An optional `integer` for + * determining the maximum number of tasks that can be run in parallel. By + * default, as many as possible. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback. Results are always returned; however, if an + * error occurs, no further `tasks` will be performed, and the results object + * will only contain partial results. Invoked with (err, results). + * @returns undefined + * @example + * + * async.auto({ + * // this function will just be passed a callback + * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'), + * showData: ['readData', function(results, cb) { + * // results.readData is the file's contents + * // ... + * }] + * }, callback); + * + * async.auto({ + * get_data: function(callback) { + * console.log('in get_data'); + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * console.log('in make_folder'); + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * console.log('in write_file', JSON.stringify(results)); + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * console.log('in email_link', JSON.stringify(results)); + * // once the file is written let's email a link to it... + * // results.write_file contains the filename returned by write_file. + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }, function(err, results) { + * console.log('err = ', err); + * console.log('results = ', results); + * }); + */ +var auto = function (tasks, concurrency, callback) { + if (typeof concurrency === 'function') { + // concurrency is optional, shift the args. + callback = concurrency; + concurrency = null; + } + callback = once(callback || noop); + var keys$$1 = keys(tasks); + var numTasks = keys$$1.length; + if (!numTasks) { + return callback(null); + } + if (!concurrency) { + concurrency = numTasks; + } + + var results = {}; + var runningTasks = 0; + var hasError = false; + + var listeners = Object.create(null); + + var readyTasks = []; + + // for cycle detection: + var readyToCheck = []; // tasks that have been identified as reachable + // without the possibility of returning to an ancestor task + var uncheckedDependencies = {}; + + baseForOwn(tasks, function (task, key) { + if (!isArray(task)) { + // no dependencies + enqueueTask(key, [task]); + readyToCheck.push(key); + return; + } + + var dependencies = task.slice(0, task.length - 1); + var remainingDependencies = dependencies.length; + if (remainingDependencies === 0) { + enqueueTask(key, task); + readyToCheck.push(key); + return; + } + uncheckedDependencies[key] = remainingDependencies; + + arrayEach(dependencies, function (dependencyName) { + if (!tasks[dependencyName]) { + throw new Error('async.auto task `' + key + + '` has a non-existent dependency `' + + dependencyName + '` in ' + + dependencies.join(', ')); + } + addListener(dependencyName, function () { + remainingDependencies--; + if (remainingDependencies === 0) { + enqueueTask(key, task); + } + }); + }); + }); + + checkForDeadlocks(); + processQueue(); + + function enqueueTask(key, task) { + readyTasks.push(function () { + runTask(key, task); + }); + } + + function processQueue() { + if (readyTasks.length === 0 && runningTasks === 0) { + return callback(null, results); + } + while(readyTasks.length && runningTasks < concurrency) { + var run = readyTasks.shift(); + run(); + } + + } + + function addListener(taskName, fn) { + var taskListeners = listeners[taskName]; + if (!taskListeners) { + taskListeners = listeners[taskName] = []; + } + + taskListeners.push(fn); + } + + function taskComplete(taskName) { + var taskListeners = listeners[taskName] || []; + arrayEach(taskListeners, function (fn) { + fn(); + }); + processQueue(); + } + + + function runTask(key, task) { + if (hasError) return; + + var taskCallback = onlyOnce(function(err, result) { + runningTasks--; + if (arguments.length > 2) { + result = slice(arguments, 1); + } + if (err) { + var safeResults = {}; + baseForOwn(results, function(val, rkey) { + safeResults[rkey] = val; + }); + safeResults[key] = result; + hasError = true; + listeners = Object.create(null); + + callback(err, safeResults); + } else { + results[key] = result; + taskComplete(key); + } + }); + + runningTasks++; + var taskFn = wrapAsync(task[task.length - 1]); + if (task.length > 1) { + taskFn(results, taskCallback); + } else { + taskFn(taskCallback); + } + } + + function checkForDeadlocks() { + // Kahn's algorithm + // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm + // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html + var currentTask; + var counter = 0; + while (readyToCheck.length) { + currentTask = readyToCheck.pop(); + counter++; + arrayEach(getDependents(currentTask), function (dependent) { + if (--uncheckedDependencies[dependent] === 0) { + readyToCheck.push(dependent); + } + }); + } + + if (counter !== numTasks) { + throw new Error( + 'async.auto cannot execute tasks due to a recursive dependency' + ); + } + } + + function getDependents(taskName) { + var result = []; + baseForOwn(tasks, function (task, key) { + if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) { + result.push(key); + } + }); + return result; + } +}; + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); +} + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined; +var symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +/** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ +function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; +} + +/** + * Casts `array` to a slice if it's needed. + * + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. + */ +function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return (!start && end >= length) ? array : baseSlice(array, start, end); +} + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the last unmatched string symbol. + */ +function charsEndIndex(strSymbols, chrSymbols) { + var index = strSymbols.length; + + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; +} + +/** + * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the first unmatched string symbol. + */ +function charsStartIndex(strSymbols, chrSymbols) { + var index = -1, + length = strSymbols.length; + + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; +} + +/** + * Converts an ASCII `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function asciiToArray(string) { + return string.split(''); +} + +/** Used to compose unicode character classes. */ +var rsAstralRange = '\\ud800-\\udfff'; +var rsComboMarksRange = '\\u0300-\\u036f'; +var reComboHalfMarksRange = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange = '\\u20d0-\\u20ff'; +var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; +var rsVarRange = '\\ufe0e\\ufe0f'; + +/** Used to compose unicode capture groups. */ +var rsZWJ = '\\u200d'; + +/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ +var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + +/** + * Checks if `string` contains Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. + */ +function hasUnicode(string) { + return reHasUnicode.test(string); +} + +/** Used to compose unicode character classes. */ +var rsAstralRange$1 = '\\ud800-\\udfff'; +var rsComboMarksRange$1 = '\\u0300-\\u036f'; +var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff'; +var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1; +var rsVarRange$1 = '\\ufe0e\\ufe0f'; + +/** Used to compose unicode capture groups. */ +var rsAstral = '[' + rsAstralRange$1 + ']'; +var rsCombo = '[' + rsComboRange$1 + ']'; +var rsFitz = '\\ud83c[\\udffb-\\udfff]'; +var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')'; +var rsNonAstral = '[^' + rsAstralRange$1 + ']'; +var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; +var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; +var rsZWJ$1 = '\\u200d'; + +/** Used to compose unicode regexes. */ +var reOptMod = rsModifier + '?'; +var rsOptVar = '[' + rsVarRange$1 + ']?'; +var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*'; +var rsSeq = rsOptVar + reOptMod + rsOptJoin; +var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + +/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ +var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + +/** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function unicodeToArray(string) { + return string.match(reUnicode) || []; +} + +/** + * Converts `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function stringToArray(string) { + return hasUnicode(string) + ? unicodeToArray(string) + : asciiToArray(string); +} + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} + +/** Used to match leading and trailing whitespace. */ +var reTrim = /^\s+|\s+$/g; + +/** + * Removes leading and trailing whitespace or specified characters from `string`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to trim. + * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the trimmed string. + * @example + * + * _.trim(' abc '); + * // => 'abc' + * + * _.trim('-_-abc-_-', '_-'); + * // => 'abc' + * + * _.map([' foo ', ' bar '], _.trim); + * // => ['foo', 'bar'] + */ +function trim(string, chars, guard) { + string = toString(string); + if (string && (guard || chars === undefined)) { + return string.replace(reTrim, ''); + } + if (!string || !(chars = baseToString(chars))) { + return string; + } + var strSymbols = stringToArray(string), + chrSymbols = stringToArray(chars), + start = charsStartIndex(strSymbols, chrSymbols), + end = charsEndIndex(strSymbols, chrSymbols) + 1; + + return castSlice(strSymbols, start, end).join(''); +} + +var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m; +var FN_ARG_SPLIT = /,/; +var FN_ARG = /(=.+)?(\s*)$/; +var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; + +function parseParams(func) { + func = func.toString().replace(STRIP_COMMENTS, ''); + func = func.match(FN_ARGS)[2].replace(' ', ''); + func = func ? func.split(FN_ARG_SPLIT) : []; + func = func.map(function (arg){ + return trim(arg.replace(FN_ARG, '')); + }); + return func; +} + +/** + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent + * tasks are specified as parameters to the function, after the usual callback + * parameter, with the parameter names matching the names of the tasks it + * depends on. This can provide even more readable task graphs which can be + * easier to maintain. + * + * If a final callback is specified, the task results are similarly injected, + * specified as named parameters after the initial error parameter. + * + * The autoInject function is purely syntactic sugar and its semantics are + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}. + * + * @name autoInject + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.auto]{@link module:ControlFlow.auto} + * @category Control Flow + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of + * the form 'func([dependencies...], callback). The object's key of a property + * serves as the name of the task defined by that property, i.e. can be used + * when specifying requirements for other tasks. + * * The `callback` parameter is a `callback(err, result)` which must be called + * when finished, passing an `error` (which can be `null`) and the result of + * the function's execution. The remaining parameters name other tasks on + * which the task is dependent, and the results from those tasks are the + * arguments of those parameters. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback, and a `results` object with any completed + * task results, similar to `auto`. + * @example + * + * // The example from `auto` can be rewritten as follows: + * async.autoInject({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: function(get_data, make_folder, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }, + * email_link: function(write_file, callback) { + * // once the file is written let's email a link to it... + * // write_file contains the filename returned by write_file. + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * } + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + * + * // If you are using a JS minifier that mangles parameter names, `autoInject` + * // will not work with plain functions, since the parameter names will be + * // collapsed to a single letter identifier. To work around this, you can + * // explicitly specify the names of the parameters your task function needs + * // in an array, similar to Angular.js dependency injection. + * + * // This still has an advantage over plain `auto`, since the results a task + * // depends on are still spread into arguments. + * async.autoInject({ + * //... + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) { + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(write_file, callback) { + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * }] + * //... + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + */ +function autoInject(tasks, callback) { + var newTasks = {}; + + baseForOwn(tasks, function (taskFn, key) { + var params; + var fnIsAsync = isAsync(taskFn); + var hasNoDeps = + (!fnIsAsync && taskFn.length === 1) || + (fnIsAsync && taskFn.length === 0); + + if (isArray(taskFn)) { + params = taskFn.slice(0, -1); + taskFn = taskFn[taskFn.length - 1]; + + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn); + } else if (hasNoDeps) { + // no dependencies, use the function as-is + newTasks[key] = taskFn; + } else { + params = parseParams(taskFn); + if (taskFn.length === 0 && !fnIsAsync && params.length === 0) { + throw new Error("autoInject task functions require explicit parameters."); + } + + // remove callback param + if (!fnIsAsync) params.pop(); + + newTasks[key] = params.concat(newTask); + } + + function newTask(results, taskCb) { + var newArgs = arrayMap(params, function (name) { + return results[name]; + }); + newArgs.push(taskCb); + wrapAsync(taskFn).apply(null, newArgs); + } + }); + + auto(newTasks, callback); +} + +// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation +// used for queues. This implementation assumes that the node provided by the user can be modified +// to adjust the next and last properties. We implement only the minimal functionality +// for queue support. +function DLL() { + this.head = this.tail = null; + this.length = 0; +} + +function setInitial(dll, node) { + dll.length = 1; + dll.head = dll.tail = node; +} + +DLL.prototype.removeLink = function(node) { + if (node.prev) node.prev.next = node.next; + else this.head = node.next; + if (node.next) node.next.prev = node.prev; + else this.tail = node.prev; + + node.prev = node.next = null; + this.length -= 1; + return node; +}; + +DLL.prototype.empty = function () { + while(this.head) this.shift(); + return this; +}; + +DLL.prototype.insertAfter = function(node, newNode) { + newNode.prev = node; + newNode.next = node.next; + if (node.next) node.next.prev = newNode; + else this.tail = newNode; + node.next = newNode; + this.length += 1; +}; + +DLL.prototype.insertBefore = function(node, newNode) { + newNode.prev = node.prev; + newNode.next = node; + if (node.prev) node.prev.next = newNode; + else this.head = newNode; + node.prev = newNode; + this.length += 1; +}; + +DLL.prototype.unshift = function(node) { + if (this.head) this.insertBefore(this.head, node); + else setInitial(this, node); +}; + +DLL.prototype.push = function(node) { + if (this.tail) this.insertAfter(this.tail, node); + else setInitial(this, node); +}; + +DLL.prototype.shift = function() { + return this.head && this.removeLink(this.head); +}; + +DLL.prototype.pop = function() { + return this.tail && this.removeLink(this.tail); +}; + +DLL.prototype.toArray = function () { + var arr = Array(this.length); + var curr = this.head; + for(var idx = 0; idx < this.length; idx++) { + arr[idx] = curr.data; + curr = curr.next; + } + return arr; +}; + +DLL.prototype.remove = function (testFn) { + var curr = this.head; + while(!!curr) { + var next = curr.next; + if (testFn(curr)) { + this.removeLink(curr); + } + curr = next; + } + return this; +}; + +function queue(worker, concurrency, payload) { + if (concurrency == null) { + concurrency = 1; + } + else if(concurrency === 0) { + throw new Error('Concurrency must not be zero'); + } + + var _worker = wrapAsync(worker); + var numRunning = 0; + var workersList = []; + + var processingScheduled = false; + function _insert(data, insertAtFront, callback) { + if (callback != null && typeof callback !== 'function') { + throw new Error('task callback must be a function'); + } + q.started = true; + if (!isArray(data)) { + data = [data]; + } + if (data.length === 0 && q.idle()) { + // call drain immediately if there are no tasks + return setImmediate$1(function() { + q.drain(); + }); + } + + for (var i = 0, l = data.length; i < l; i++) { + var item = { + data: data[i], + callback: callback || noop + }; + + if (insertAtFront) { + q._tasks.unshift(item); + } else { + q._tasks.push(item); + } + } + + if (!processingScheduled) { + processingScheduled = true; + setImmediate$1(function() { + processingScheduled = false; + q.process(); + }); + } + } + + function _next(tasks) { + return function(err){ + numRunning -= 1; + + for (var i = 0, l = tasks.length; i < l; i++) { + var task = tasks[i]; + + var index = baseIndexOf(workersList, task, 0); + if (index === 0) { + workersList.shift(); + } else if (index > 0) { + workersList.splice(index, 1); + } + + task.callback.apply(task, arguments); + + if (err != null) { + q.error(err, task.data); + } + } + + if (numRunning <= (q.concurrency - q.buffer) ) { + q.unsaturated(); + } + + if (q.idle()) { + q.drain(); + } + q.process(); + }; + } + + var isProcessing = false; + var q = { + _tasks: new DLL(), + concurrency: concurrency, + payload: payload, + saturated: noop, + unsaturated:noop, + buffer: concurrency / 4, + empty: noop, + drain: noop, + error: noop, + started: false, + paused: false, + push: function (data, callback) { + _insert(data, false, callback); + }, + kill: function () { + q.drain = noop; + q._tasks.empty(); + }, + unshift: function (data, callback) { + _insert(data, true, callback); + }, + remove: function (testFn) { + q._tasks.remove(testFn); + }, + process: function () { + // Avoid trying to start too many processing operations. This can occur + // when callbacks resolve synchronously (#1267). + if (isProcessing) { + return; + } + isProcessing = true; + while(!q.paused && numRunning < q.concurrency && q._tasks.length){ + var tasks = [], data = []; + var l = q._tasks.length; + if (q.payload) l = Math.min(l, q.payload); + for (var i = 0; i < l; i++) { + var node = q._tasks.shift(); + tasks.push(node); + workersList.push(node); + data.push(node.data); + } + + numRunning += 1; + + if (q._tasks.length === 0) { + q.empty(); + } + + if (numRunning === q.concurrency) { + q.saturated(); + } + + var cb = onlyOnce(_next(tasks)); + _worker(data, cb); + } + isProcessing = false; + }, + length: function () { + return q._tasks.length; + }, + running: function () { + return numRunning; + }, + workersList: function () { + return workersList; + }, + idle: function() { + return q._tasks.length + numRunning === 0; + }, + pause: function () { + q.paused = true; + }, + resume: function () { + if (q.paused === false) { return; } + q.paused = false; + setImmediate$1(q.process); + } + }; + return q; +} + +/** + * A cargo of tasks for the worker function to complete. Cargo inherits all of + * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}. + * @typedef {Object} CargoObject + * @memberOf module:ControlFlow + * @property {Function} length - A function returning the number of items + * waiting to be processed. Invoke like `cargo.length()`. + * @property {number} payload - An `integer` for determining how many tasks + * should be process per round. This property can be changed after a `cargo` is + * created to alter the payload on-the-fly. + * @property {Function} push - Adds `task` to the `queue`. The callback is + * called once the `worker` has finished processing the task. Instead of a + * single task, an array of `tasks` can be submitted. The respective callback is + * used for every task in the list. Invoke like `cargo.push(task, [callback])`. + * @property {Function} saturated - A callback that is called when the + * `queue.length()` hits the concurrency and further tasks will be queued. + * @property {Function} empty - A callback that is called when the last item + * from the `queue` is given to a `worker`. + * @property {Function} drain - A callback that is called when the last item + * from the `queue` has returned from the `worker`. + * @property {Function} idle - a function returning false if there are items + * waiting or being processed, or true if not. Invoke like `cargo.idle()`. + * @property {Function} pause - a function that pauses the processing of tasks + * until `resume()` is called. Invoke like `cargo.pause()`. + * @property {Function} resume - a function that resumes the processing of + * queued tasks when the queue is paused. Invoke like `cargo.resume()`. + * @property {Function} kill - a function that removes the `drain` callback and + * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`. + */ + +/** + * Creates a `cargo` object with the specified payload. Tasks added to the + * cargo will be processed altogether (up to the `payload` limit). If the + * `worker` is in progress, the task is queued until it becomes available. Once + * the `worker` has completed some tasks, each callback of those tasks is + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) + * for how `cargo` and `queue` work. + * + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers + * at a time, cargo passes an array of tasks to a single worker, repeating + * when the worker is finished. + * + * @name cargo + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An asynchronous function for processing an array + * of queued tasks. Invoked with `(tasks, callback)`. + * @param {number} [payload=Infinity] - An optional `integer` for determining + * how many tasks should be processed per round; if omitted, the default is + * unlimited. + * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can + * attached as certain properties to listen for specific events during the + * lifecycle of the cargo and inner queue. + * @example + * + * // create a cargo object with payload 2 + * var cargo = async.cargo(function(tasks, callback) { + * for (var i=0; i true + */ +function identity(value) { + return value; +} + +function _createTester(check, getResult) { + return function(eachfn, arr, iteratee, cb) { + cb = cb || noop; + var testPassed = false; + var testResult; + eachfn(arr, function(value, _, callback) { + iteratee(value, function(err, result) { + if (err) { + callback(err); + } else if (check(result) && !testResult) { + testPassed = true; + testResult = getResult(true, value); + callback(null, breakLoop); + } else { + callback(); + } + }); + }, function(err) { + if (err) { + cb(err); + } else { + cb(null, testPassed ? testResult : getResult(false)); + } + }); + }; +} + +function _findGetResult(v, x) { + return x; +} + +/** + * Returns the first value in `coll` that passes an async truth test. The + * `iteratee` is applied in parallel, meaning the first iteratee to return + * `true` will fire the detect `callback` with that result. That means the + * result might not be the first item in the original `coll` (in terms of order) + * that passes the test. + + * If order within the original `coll` is important, then look at + * [`detectSeries`]{@link module:Collections.detectSeries}. + * + * @name detect + * @static + * @memberOf module:Collections + * @method + * @alias find + * @category Collections + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @example + * + * async.detect(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, result) { + * // result now equals the first file in the list that exists + * }); + */ +var detect = doParallel(_createTester(identity, _findGetResult)); + +/** + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a + * time. + * + * @name detectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findLimit + * @category Collections + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + */ +var detectLimit = doParallelLimit(_createTester(identity, _findGetResult)); + +/** + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time. + * + * @name detectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findSeries + * @category Collections + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + */ +var detectSeries = doLimit(detectLimit, 1); + +function consoleFunc(name) { + return function (fn/*, ...args*/) { + var args = slice(arguments, 1); + args.push(function (err/*, ...args*/) { + var args = slice(arguments, 1); + if (typeof console === 'object') { + if (err) { + if (console.error) { + console.error(err); + } + } else if (console[name]) { + arrayEach(args, function (x) { + console[name](x); + }); + } + } + }); + wrapAsync(fn).apply(null, args); + }; +} + +/** + * Logs the result of an [`async` function]{@link AsyncFunction} to the + * `console` using `console.dir` to display the properties of the resulting object. + * Only works in Node.js or in browsers that support `console.dir` and + * `console.error` (such as FF and Chrome). + * If multiple arguments are returned from the async function, + * `console.dir` is called on each argument in order. + * + * @name dir + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, {hello: name}); + * }, 1000); + * }; + * + * // in the node repl + * node> async.dir(hello, 'world'); + * {hello: 'world'} + */ +var dir = consoleFunc('dir'); + +/** + * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in + * the order of operations, the arguments `test` and `fn` are switched. + * + * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function. + * @name doDuring + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.during]{@link module:ControlFlow.during} + * @category Control Flow + * @param {AsyncFunction} fn - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `fn`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `fn`. + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `fn` has stopped. `callback` + * will be passed an error if one occurred, otherwise `null`. + */ +function doDuring(fn, test, callback) { + callback = onlyOnce(callback || noop); + var _fn = wrapAsync(fn); + var _test = wrapAsync(test); + + function next(err/*, ...args*/) { + if (err) return callback(err); + var args = slice(arguments, 1); + args.push(check); + _test.apply(this, args); + } + + function check(err, truth) { + if (err) return callback(err); + if (!truth) return callback(null); + _fn(next); + } + + check(null, true); + +} + +/** + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in + * the order of operations, the arguments `test` and `iteratee` are switched. + * + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. + * + * @name doWhilst + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - A function which is called each time `test` + * passes. Invoked with (callback). + * @param {Function} test - synchronous truth test to perform after each + * execution of `iteratee`. Invoked with any non-error callback results of + * `iteratee`. + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. + * `callback` will be passed an error and any arguments passed to the final + * `iteratee`'s callback. Invoked with (err, [results]); + */ +function doWhilst(iteratee, test, callback) { + callback = onlyOnce(callback || noop); + var _iteratee = wrapAsync(iteratee); + var next = function(err/*, ...args*/) { + if (err) return callback(err); + var args = slice(arguments, 1); + if (test.apply(this, args)) return _iteratee(next); + callback.apply(null, [null].concat(args)); + }; + _iteratee(next); +} + +/** + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the + * argument ordering differs from `until`. + * + * @name doUntil + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {Function} test - synchronous truth test to perform after each + * execution of `iteratee`. Invoked with any non-error callback results of + * `iteratee`. + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + */ +function doUntil(iteratee, test, callback) { + doWhilst(iteratee, function() { + return !test.apply(this, arguments); + }, callback); +} + +/** + * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that + * is passed a callback in the form of `function (err, truth)`. If error is + * passed to `test` or `fn`, the main callback is immediately called with the + * value of the error. + * + * @name during + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `fn`. Invoked with (callback). + * @param {AsyncFunction} fn - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `fn` has stopped. `callback` + * will be passed an error, if one occurred, otherwise `null`. + * @example + * + * var count = 0; + * + * async.during( + * function (callback) { + * return callback(null, count < 5); + * }, + * function (callback) { + * count++; + * setTimeout(callback, 1000); + * }, + * function (err) { + * // 5 seconds have passed + * } + * ); + */ +function during(test, fn, callback) { + callback = onlyOnce(callback || noop); + var _fn = wrapAsync(fn); + var _test = wrapAsync(test); + + function next(err) { + if (err) return callback(err); + _test(check); + } + + function check(err, truth) { + if (err) return callback(err); + if (!truth) return callback(null); + _fn(next); + } + + _test(check); +} + +function _withoutIndex(iteratee) { + return function (value, index, callback) { + return iteratee(value, callback); + }; +} + +/** + * Applies the function `iteratee` to each item in `coll`, in parallel. + * The `iteratee` is called with an item from the list, and a callback for when + * it has finished. If the `iteratee` passes an error to its `callback`, the + * main `callback` (for the `each` function) is immediately called with the + * error. + * + * Note, that since this function applies `iteratee` to each item in parallel, + * there is no guarantee that the iteratee functions will complete in order. + * + * @name each + * @static + * @memberOf module:Collections + * @method + * @alias forEach + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to + * each item in `coll`. Invoked with (item, callback). + * The array index is not passed to the iteratee. + * If you need the index, use `eachOf`. + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @example + * + * // assuming openFiles is an array of file names and saveFile is a function + * // to save the modified contents of that file: + * + * async.each(openFiles, saveFile, function(err){ + * // if any of the saves produced an error, err would equal that error + * }); + * + * // assuming openFiles is an array of file names + * async.each(openFiles, function(file, callback) { + * + * // Perform operation on file here. + * console.log('Processing file ' + file); + * + * if( file.length > 32 ) { + * console.log('This file name is too long'); + * callback('File name too long'); + * } else { + * // Do work to process file here + * console.log('File processed'); + * callback(); + * } + * }, function(err) { + * // if any of the file processing produced an error, err would equal that error + * if( err ) { + * // One of the iterations produced an error. + * // All processing will now stop. + * console.log('A file failed to process'); + * } else { + * console.log('All files have been processed successfully'); + * } + * }); + */ +function eachLimit(coll, iteratee, callback) { + eachOf(coll, _withoutIndex(wrapAsync(iteratee)), callback); +} + +/** + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. + * + * @name eachLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfLimit`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + */ +function eachLimit$1(coll, limit, iteratee, callback) { + _eachOfLimit(limit)(coll, _withoutIndex(wrapAsync(iteratee)), callback); +} + +/** + * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. + * + * @name eachSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachSeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfSeries`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + */ +var eachSeries = doLimit(eachLimit$1, 1); + +/** + * Wrap an async function and ensure it calls its callback on a later tick of + * the event loop. If the function already calls its callback on a next tick, + * no extra deferral is added. This is useful for preventing stack overflows + * (`RangeError: Maximum call stack size exceeded`) and generally keeping + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) + * contained. ES2017 `async` functions are returned as-is -- they are immune + * to Zalgo's corrupting influences, as they always resolve on a later tick. + * + * @name ensureAsync + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - an async function, one that expects a node-style + * callback as its last argument. + * @returns {AsyncFunction} Returns a wrapped function with the exact same call + * signature as the function passed in. + * @example + * + * function sometimesAsync(arg, callback) { + * if (cache[arg]) { + * return callback(null, cache[arg]); // this would be synchronous!! + * } else { + * doSomeIO(arg, callback); // this IO would be asynchronous + * } + * } + * + * // this has a risk of stack overflows if many results are cached in a row + * async.mapSeries(args, sometimesAsync, done); + * + * // this will defer sometimesAsync's callback if necessary, + * // preventing stack overflows + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done); + */ +function ensureAsync(fn) { + if (isAsync(fn)) return fn; + return initialParams(function (args, callback) { + var sync = true; + args.push(function () { + var innerArgs = arguments; + if (sync) { + setImmediate$1(function () { + callback.apply(null, innerArgs); + }); + } else { + callback.apply(null, innerArgs); + } + }); + fn.apply(this, args); + sync = false; + }); +} + +function notId(v) { + return !v; +} + +/** + * Returns `true` if every element in `coll` satisfies an async test. If any + * iteratee call returns `false`, the main `callback` is immediately called. + * + * @name every + * @static + * @memberOf module:Collections + * @method + * @alias all + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @example + * + * async.every(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, result) { + * // if result is true then every file exists + * }); + */ +var every = doParallel(_createTester(notId, notId)); + +/** + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time. + * + * @name everyLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + */ +var everyLimit = doParallelLimit(_createTester(notId, notId)); + +/** + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time. + * + * @name everySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allSeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in series. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + */ +var everySeries = doLimit(everyLimit, 1); + +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} + +function filterArray(eachfn, arr, iteratee, callback) { + var truthValues = new Array(arr.length); + eachfn(arr, function (x, index, callback) { + iteratee(x, function (err, v) { + truthValues[index] = !!v; + callback(err); + }); + }, function (err) { + if (err) return callback(err); + var results = []; + for (var i = 0; i < arr.length; i++) { + if (truthValues[i]) results.push(arr[i]); + } + callback(null, results); + }); +} + +function filterGeneric(eachfn, coll, iteratee, callback) { + var results = []; + eachfn(coll, function (x, index, callback) { + iteratee(x, function (err, v) { + if (err) { + callback(err); + } else { + if (v) { + results.push({index: index, value: x}); + } + callback(); + } + }); + }, function (err) { + if (err) { + callback(err); + } else { + callback(null, arrayMap(results.sort(function (a, b) { + return a.index - b.index; + }), baseProperty('value'))); + } + }); +} + +function _filter(eachfn, coll, iteratee, callback) { + var filter = isArrayLike(coll) ? filterArray : filterGeneric; + filter(eachfn, coll, wrapAsync(iteratee), callback || noop); +} + +/** + * Returns a new array of all the values in `coll` which pass an async truth + * test. This operation is performed in parallel, but the results array will be + * in the same order as the original. + * + * @name filter + * @static + * @memberOf module:Collections + * @method + * @alias select + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @example + * + * async.filter(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, results) { + * // results now equals an array of the existing files + * }); + */ +var filter = doParallel(_filter); + +/** + * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a + * time. + * + * @name filterLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + */ +var filterLimit = doParallelLimit(_filter); + +/** + * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time. + * + * @name filterSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectSeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results) + */ +var filterSeries = doLimit(filterLimit, 1); + +/** + * Calls the asynchronous function `fn` with a callback parameter that allows it + * to call itself again, in series, indefinitely. + + * If an error is passed to the callback then `errback` is called with the + * error, and execution stops, otherwise it will never be called. + * + * @name forever + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} fn - an async function to call repeatedly. + * Invoked with (next). + * @param {Function} [errback] - when `fn` passes an error to it's callback, + * this function will be called, and execution stops. Invoked with (err). + * @example + * + * async.forever( + * function(next) { + * // next is suitable for passing to things that need a callback(err [, whatever]); + * // it will result in this function being called again. + * }, + * function(err) { + * // if next is called with a value in its first parameter, it will appear + * // in here as 'err', and execution will stop. + * } + * ); + */ +function forever(fn, errback) { + var done = onlyOnce(errback || noop); + var task = wrapAsync(ensureAsync(fn)); + + function next(err) { + if (err) return done(err); + task(next); + } + next(); +} + +/** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time. + * + * @name groupByLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + */ +var groupByLimit = function(coll, limit, iteratee, callback) { + callback = callback || noop; + var _iteratee = wrapAsync(iteratee); + mapLimit(coll, limit, function(val, callback) { + _iteratee(val, function(err, key) { + if (err) return callback(err); + return callback(null, {key: key, val: val}); + }); + }, function(err, mapResults) { + var result = {}; + // from MDN, handle object having an `hasOwnProperty` prop + var hasOwnProperty = Object.prototype.hasOwnProperty; + + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + var key = mapResults[i].key; + var val = mapResults[i].val; + + if (hasOwnProperty.call(result, key)) { + result[key].push(val); + } else { + result[key] = [val]; + } + } + } + + return callback(err, result); + }); +}; + +/** + * Returns a new object, where each value corresponds to an array of items, from + * `coll`, that returned the corresponding key. That is, the keys of the object + * correspond to the values passed to the `iteratee` callback. + * + * Note: Since this function applies the `iteratee` to each item in parallel, + * there is no guarantee that the `iteratee` functions will complete in order. + * However, the values for each key in the `result` will be in the same order as + * the original `coll`. For Objects, the values will roughly be in the order of + * the original Objects' keys (but this can vary across JavaScript engines). + * + * @name groupBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + * @example + * + * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) { + * db.findById(userId, function(err, user) { + * if (err) return callback(err); + * return callback(null, user.age); + * }); + * }, function(err, result) { + * // result is object containing the userIds grouped by age + * // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']}; + * }); + */ +var groupBy = doLimit(groupByLimit, Infinity); + +/** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time. + * + * @name groupBySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + */ +var groupBySeries = doLimit(groupByLimit, 1); + +/** + * Logs the result of an `async` function to the `console`. Only works in + * Node.js or in browsers that support `console.log` and `console.error` (such + * as FF and Chrome). If multiple arguments are returned from the async + * function, `console.log` is called on each argument in order. + * + * @name log + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, 'hello ' + name); + * }, 1000); + * }; + * + * // in the node repl + * node> async.log(hello, 'world'); + * 'hello world' + */ +var log = consoleFunc('log'); + +/** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a + * time. + * + * @name mapValuesLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + */ +function mapValuesLimit(obj, limit, iteratee, callback) { + callback = once(callback || noop); + var newObj = {}; + var _iteratee = wrapAsync(iteratee); + eachOfLimit(obj, limit, function(val, key, next) { + _iteratee(val, key, function (err, result) { + if (err) return next(err); + newObj[key] = result; + next(); + }); + }, function (err) { + callback(err, newObj); + }); +} + +/** + * A relative of [`map`]{@link module:Collections.map}, designed for use with objects. + * + * Produces a new Object by mapping each value of `obj` through the `iteratee` + * function. The `iteratee` is called each `value` and `key` from `obj` and a + * callback for when it has finished processing. Each of these callbacks takes + * two arguments: an `error`, and the transformed item from `obj`. If `iteratee` + * passes an error to its callback, the main `callback` (for the `mapValues` + * function) is immediately called with the error. + * + * Note, the order of the keys in the result is not guaranteed. The keys will + * be roughly in the order they complete, (but this is very engine-specific) + * + * @name mapValues + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @example + * + * async.mapValues({ + * f1: 'file1', + * f2: 'file2', + * f3: 'file3' + * }, function (file, key, callback) { + * fs.stat(file, callback); + * }, function(err, result) { + * // result is now a map of stats for each file, e.g. + * // { + * // f1: [stats for file1], + * // f2: [stats for file2], + * // f3: [stats for file3] + * // } + * }); + */ + +var mapValues = doLimit(mapValuesLimit, Infinity); + +/** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time. + * + * @name mapValuesSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + */ +var mapValuesSeries = doLimit(mapValuesLimit, 1); + +function has(obj, key) { + return key in obj; +} + +/** + * Caches the results of an async function. When creating a hash to store + * function results against, the callback is omitted from the hash and an + * optional hash function can be used. + * + * If no hash function is specified, the first argument is used as a hash key, + * which may work reasonably if it is a string or a data type that converts to a + * distinct string. Note that objects and arrays will not behave reasonably. + * Neither will cases where the other arguments are significant. In such cases, + * specify your own hash function. + * + * The cache of results is exposed as the `memo` property of the function + * returned by `memoize`. + * + * @name memoize + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function to proxy and cache results from. + * @param {Function} hasher - An optional function for generating a custom hash + * for storing results. It has all the arguments applied to it apart from the + * callback, and must be synchronous. + * @returns {AsyncFunction} a memoized version of `fn` + * @example + * + * var slow_fn = function(name, callback) { + * // do something + * callback(null, result); + * }; + * var fn = async.memoize(slow_fn); + * + * // fn can now be used as if it were slow_fn + * fn('some name', function() { + * // callback + * }); + */ +function memoize(fn, hasher) { + var memo = Object.create(null); + var queues = Object.create(null); + hasher = hasher || identity; + var _fn = wrapAsync(fn); + var memoized = initialParams(function memoized(args, callback) { + var key = hasher.apply(null, args); + if (has(memo, key)) { + setImmediate$1(function() { + callback.apply(null, memo[key]); + }); + } else if (has(queues, key)) { + queues[key].push(callback); + } else { + queues[key] = [callback]; + _fn.apply(null, args.concat(function(/*args*/) { + var args = slice(arguments); + memo[key] = args; + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i].apply(null, args); + } + })); + } + }); + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; +} + +/** + * Calls `callback` on a later loop around the event loop. In Node.js this just + * calls `process.nextTicl`. In the browser it will use `setImmediate` if + * available, otherwise `setTimeout(callback, 0)`, which means other higher + * priority events may precede the execution of `callback`. + * + * This is used internally for browser-compatibility purposes. + * + * @name nextTick + * @static + * @memberOf module:Utils + * @method + * @see [async.setImmediate]{@link module:Utils.setImmediate} + * @category Util + * @param {Function} callback - The function to call on a later loop around + * the event loop. Invoked with (args...). + * @param {...*} args... - any number of additional arguments to pass to the + * callback on the next tick. + * @example + * + * var call_order = []; + * async.nextTick(function() { + * call_order.push('two'); + * // call_order now equals ['one','two'] + * }); + * call_order.push('one'); + * + * async.setImmediate(function (a, b, c) { + * // a, b, and c equal 1, 2, and 3 + * }, 1, 2, 3); + */ +var _defer$1; + +if (hasNextTick) { + _defer$1 = process.nextTick; +} else if (hasSetImmediate) { + _defer$1 = setImmediate; +} else { + _defer$1 = fallback; +} + +var nextTick = wrap(_defer$1); + +function _parallel(eachfn, tasks, callback) { + callback = callback || noop; + var results = isArrayLike(tasks) ? [] : {}; + + eachfn(tasks, function (task, key, callback) { + wrapAsync(task)(function (err, result) { + if (arguments.length > 2) { + result = slice(arguments, 1); + } + results[key] = result; + callback(err); + }); + }, function (err) { + callback(err, results); + }); +} + +/** + * Run the `tasks` collection of functions in parallel, without waiting until + * the previous function has completed. If any of the functions pass an error to + * its callback, the main `callback` is immediately called with the value of the + * error. Once the `tasks` have completed, the results are passed to the final + * `callback` as an array. + * + * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about + * parallel execution of code. If your tasks do not use any timers or perform + * any I/O, they will actually be executed in series. Any synchronous setup + * sections for each task will happen one after the other. JavaScript remains + * single-threaded. + * + * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the + * execution of other tasks when a task fails. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.parallel}. + * + * @name parallel + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + * + * @example + * async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], + * // optional callback + * function(err, results) { + * // the results array will equal ['one','two'] even though + * // the second function had a shorter timeout. + * }); + * + * // an example using an object instead of an array + * async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * // results is now equals to: {one: 1, two: 2} + * }); + */ +function parallelLimit(tasks, callback) { + _parallel(eachOf, tasks, callback); +} + +/** + * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a + * time. + * + * @name parallelLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.parallel]{@link module:ControlFlow.parallel} + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + */ +function parallelLimit$1(tasks, limit, callback) { + _parallel(_eachOfLimit(limit), tasks, callback); +} + +/** + * A queue of tasks for the worker function to complete. + * @typedef {Object} QueueObject + * @memberOf module:ControlFlow + * @property {Function} length - a function returning the number of items + * waiting to be processed. Invoke with `queue.length()`. + * @property {boolean} started - a boolean indicating whether or not any + * items have been pushed and processed by the queue. + * @property {Function} running - a function returning the number of items + * currently being processed. Invoke with `queue.running()`. + * @property {Function} workersList - a function returning the array of items + * currently being processed. Invoke with `queue.workersList()`. + * @property {Function} idle - a function returning false if there are items + * waiting or being processed, or true if not. Invoke with `queue.idle()`. + * @property {number} concurrency - an integer for determining how many `worker` + * functions should be run in parallel. This property can be changed after a + * `queue` is created to alter the concurrency on-the-fly. + * @property {Function} push - add a new task to the `queue`. Calls `callback` + * once the `worker` has finished processing the task. Instead of a single task, + * a `tasks` array can be submitted. The respective callback is used for every + * task in the list. Invoke with `queue.push(task, [callback])`, + * @property {Function} unshift - add a new task to the front of the `queue`. + * Invoke with `queue.unshift(task, [callback])`. + * @property {Function} remove - remove items from the queue that match a test + * function. The test function will be passed an object with a `data` property, + * and a `priority` property, if this is a + * [priorityQueue]{@link module:ControlFlow.priorityQueue} object. + * Invoked with `queue.remove(testFn)`, where `testFn` is of the form + * `function ({data, priority}) {}` and returns a Boolean. + * @property {Function} saturated - a callback that is called when the number of + * running workers hits the `concurrency` limit, and further tasks will be + * queued. + * @property {Function} unsaturated - a callback that is called when the number + * of running workers is less than the `concurrency` & `buffer` limits, and + * further tasks will not be queued. + * @property {number} buffer - A minimum threshold buffer in order to say that + * the `queue` is `unsaturated`. + * @property {Function} empty - a callback that is called when the last item + * from the `queue` is given to a `worker`. + * @property {Function} drain - a callback that is called when the last item + * from the `queue` has returned from the `worker`. + * @property {Function} error - a callback that is called when a task errors. + * Has the signature `function(error, task)`. + * @property {boolean} paused - a boolean for determining whether the queue is + * in a paused state. + * @property {Function} pause - a function that pauses the processing of tasks + * until `resume()` is called. Invoke with `queue.pause()`. + * @property {Function} resume - a function that resumes the processing of + * queued tasks when the queue is paused. Invoke with `queue.resume()`. + * @property {Function} kill - a function that removes the `drain` callback and + * empties remaining tasks from the queue forcing it to go idle. No more tasks + * should be pushed to the queue after calling this function. Invoke with `queue.kill()`. + */ + +/** + * Creates a `queue` object with the specified `concurrency`. Tasks added to the + * `queue` are processed in parallel (up to the `concurrency` limit). If all + * `worker`s are in progress, the task is queued until one becomes available. + * Once a `worker` completes a `task`, that `task`'s callback is called. + * + * @name queue + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. Invoked with (task, callback). + * @param {number} [concurrency=1] - An `integer` for determining how many + * `worker` functions should be run in parallel. If omitted, the concurrency + * defaults to `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can + * attached as certain properties to listen for specific events during the + * lifecycle of the queue. + * @example + * + * // create a queue object with concurrency 2 + * var q = async.queue(function(task, callback) { + * console.log('hello ' + task.name); + * callback(); + * }, 2); + * + * // assign a callback + * q.drain = function() { + * console.log('all items have been processed'); + * }; + * + * // add some items to the queue + * q.push({name: 'foo'}, function(err) { + * console.log('finished processing foo'); + * }); + * q.push({name: 'bar'}, function (err) { + * console.log('finished processing bar'); + * }); + * + * // add some items to the queue (batch-wise) + * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) { + * console.log('finished processing item'); + * }); + * + * // add some items to the front of the queue + * q.unshift({name: 'bar'}, function (err) { + * console.log('finished processing bar'); + * }); + */ +var queue$1 = function (worker, concurrency) { + var _worker = wrapAsync(worker); + return queue(function (items, cb) { + _worker(items[0], cb); + }, concurrency, 1); +}; + +/** + * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and + * completed in ascending priority order. + * + * @name priorityQueue + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. + * Invoked with (task, callback). + * @param {number} concurrency - An `integer` for determining how many `worker` + * functions should be run in parallel. If omitted, the concurrency defaults to + * `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two + * differences between `queue` and `priorityQueue` objects: + * * `push(task, priority, [callback])` - `priority` should be a number. If an + * array of `tasks` is given, all tasks will be assigned the same priority. + * * The `unshift` method was removed. + */ +var priorityQueue = function(worker, concurrency) { + // Start with a normal queue + var q = queue$1(worker, concurrency); + + // Override push to accept second parameter representing priority + q.push = function(data, priority, callback) { + if (callback == null) callback = noop; + if (typeof callback !== 'function') { + throw new Error('task callback must be a function'); + } + q.started = true; + if (!isArray(data)) { + data = [data]; + } + if (data.length === 0) { + // call drain immediately if there are no tasks + return setImmediate$1(function() { + q.drain(); + }); + } + + priority = priority || 0; + var nextNode = q._tasks.head; + while (nextNode && priority >= nextNode.priority) { + nextNode = nextNode.next; + } + + for (var i = 0, l = data.length; i < l; i++) { + var item = { + data: data[i], + priority: priority, + callback: callback + }; + + if (nextNode) { + q._tasks.insertBefore(nextNode, item); + } else { + q._tasks.push(item); + } + } + setImmediate$1(q.process); + }; + + // Remove unshift function + delete q.unshift; + + return q; +}; + +/** + * Runs the `tasks` array of functions in parallel, without waiting until the + * previous function has completed. Once any of the `tasks` complete or pass an + * error to its callback, the main `callback` is immediately called. It's + * equivalent to `Promise.race()`. + * + * @name race + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction} + * to run. Each function can complete with an optional `result` value. + * @param {Function} callback - A callback to run once any of the functions have + * completed. This function gets an error or result from the first function that + * completed. Invoked with (err, result). + * @returns undefined + * @example + * + * async.race([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], + * // main callback + * function(err, result) { + * // the result will be equal to 'two' as it finishes earlier + * }); + */ +function race(tasks, callback) { + callback = once(callback || noop); + if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); + if (!tasks.length) return callback(); + for (var i = 0, l = tasks.length; i < l; i++) { + wrapAsync(tasks[i])(callback); + } +} + +/** + * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. + * + * @name reduceRight + * @static + * @memberOf module:Collections + * @method + * @see [async.reduce]{@link module:Collections.reduce} + * @alias foldr + * @category Collection + * @param {Array} array - A collection to iterate over. + * @param {*} memo - The initial state of the reduction. + * @param {AsyncFunction} iteratee - A function applied to each item in the + * array to produce the next step in the reduction. + * The `iteratee` should complete with the next state of the reduction. + * If the iteratee complete with an error, the reduction is stopped and the + * main `callback` is immediately called with the error. + * Invoked with (memo, item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the reduced value. Invoked with + * (err, result). + */ +function reduceRight (array, memo, iteratee, callback) { + var reversed = slice(array).reverse(); + reduce(reversed, memo, iteratee, callback); +} + +/** + * Wraps the async function in another function that always completes with a + * result object, even when it errors. + * + * The result object has either the property `error` or `value`. + * + * @name reflect + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function you want to wrap + * @returns {Function} - A function that always passes null to it's callback as + * the error. The second argument to the callback will be an `object` with + * either an `error` or a `value` property. + * @example + * + * async.parallel([ + * async.reflect(function(callback) { + * // do some stuff ... + * callback(null, 'one'); + * }), + * async.reflect(function(callback) { + * // do some more stuff but error ... + * callback('bad stuff happened'); + * }), + * async.reflect(function(callback) { + * // do some more stuff ... + * callback(null, 'two'); + * }) + * ], + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = 'bad stuff happened' + * // results[2].value = 'two' + * }); + */ +function reflect(fn) { + var _fn = wrapAsync(fn); + return initialParams(function reflectOn(args, reflectCallback) { + args.push(function callback(error, cbArg) { + if (error) { + reflectCallback(null, { error: error }); + } else { + var value; + if (arguments.length <= 2) { + value = cbArg; + } else { + value = slice(arguments, 1); + } + reflectCallback(null, { value: value }); + } + }); + + return _fn.apply(this, args); + }); +} + +/** + * A helper function that wraps an array or an object of functions with `reflect`. + * + * @name reflectAll + * @static + * @memberOf module:Utils + * @method + * @see [async.reflect]{@link module:Utils.reflect} + * @category Util + * @param {Array|Object|Iterable} tasks - The collection of + * [async functions]{@link AsyncFunction} to wrap in `async.reflect`. + * @returns {Array} Returns an array of async functions, each wrapped in + * `async.reflect` + * @example + * + * let tasks = [ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * // do some more stuff but error ... + * callback(new Error('bad stuff happened')); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = Error('bad stuff happened') + * // results[2].value = 'two' + * }); + * + * // an example using an object instead of an array + * let tasks = { + * one: function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * two: function(callback) { + * callback('two'); + * }, + * three: function(callback) { + * setTimeout(function() { + * callback(null, 'three'); + * }, 100); + * } + * }; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results.one.value = 'one' + * // results.two.error = 'two' + * // results.three.value = 'three' + * }); + */ +function reflectAll(tasks) { + var results; + if (isArray(tasks)) { + results = arrayMap(tasks, reflect); + } else { + results = {}; + baseForOwn(tasks, function(task, key) { + results[key] = reflect.call(this, task); + }); + } + return results; +} + +function reject$1(eachfn, arr, iteratee, callback) { + _filter(eachfn, arr, function(value, cb) { + iteratee(value, function(err, v) { + cb(err, !v); + }); + }, callback); +} + +/** + * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test. + * + * @name reject + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @example + * + * async.reject(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, results) { + * // results now equals an array of missing files + * createFiles(results); + * }); + */ +var reject = doParallel(reject$1); + +/** + * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a + * time. + * + * @name rejectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + */ +var rejectLimit = doParallelLimit(reject$1); + +/** + * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time. + * + * @name rejectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + */ +var rejectSeries = doLimit(rejectLimit, 1); + +/** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. + * @example + * + * var objects = _.times(2, _.constant({ 'a': 1 })); + * + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); + * // => true + */ +function constant$1(value) { + return function() { + return value; + }; +} + +/** + * Attempts to get a successful response from `task` no more than `times` times + * before returning an error. If the task is successful, the `callback` will be + * passed the result of the successful task. If all attempts fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name retry + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @see [async.retryable]{@link module:ControlFlow.retryable} + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an + * object with `times` and `interval` or a number. + * * `times` - The number of attempts to make before giving up. The default + * is `5`. + * * `interval` - The time to wait between retries, in milliseconds. The + * default is `0`. The interval may also be specified as a function of the + * retry count (see example). + * * `errorFilter` - An optional synchronous function that is invoked on + * erroneous result. If it returns `true` the retry attempts will continue; + * if the function returns `false` the retry flow is aborted with the current + * attempt's error and result being returned to the final callback. + * Invoked with (err). + * * If `opts` is a number, the number specifies the number of times to retry, + * with the default interval of `0`. + * @param {AsyncFunction} task - An async function to retry. + * Invoked with (callback). + * @param {Function} [callback] - An optional callback which is called when the + * task has succeeded, or after the final failed attempt. It receives the `err` + * and `result` arguments of the last attempt at completing the `task`. Invoked + * with (err, results). + * + * @example + * + * // The `retry` function can be used as a stand-alone control flow by passing + * // a callback, as shown below: + * + * // try calling apiMethod 3 times + * async.retry(3, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 3 times, waiting 200 ms between each retry + * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 10 times with exponential backoff + * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds) + * async.retry({ + * times: 10, + * interval: function(retryCount) { + * return 50 * Math.pow(2, retryCount); + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod the default 5 times no delay between each retry + * async.retry(apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod only when error condition satisfies, all other + * // errors will abort the retry control flow and return to final callback + * async.retry({ + * errorFilter: function(err) { + * return err.message === 'Temporary error'; // only retry on a specific error + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // to retry individual methods that are not as reliable within other + * // control flow functions, use the `retryable` wrapper: + * async.auto({ + * users: api.getUsers.bind(api), + * payments: async.retryable(3, api.getPayments.bind(api)) + * }, function(err, results) { + * // do something with the results + * }); + * + */ +function retry(opts, task, callback) { + var DEFAULT_TIMES = 5; + var DEFAULT_INTERVAL = 0; + + var options = { + times: DEFAULT_TIMES, + intervalFunc: constant$1(DEFAULT_INTERVAL) + }; + + function parseTimes(acc, t) { + if (typeof t === 'object') { + acc.times = +t.times || DEFAULT_TIMES; + + acc.intervalFunc = typeof t.interval === 'function' ? + t.interval : + constant$1(+t.interval || DEFAULT_INTERVAL); + + acc.errorFilter = t.errorFilter; + } else if (typeof t === 'number' || typeof t === 'string') { + acc.times = +t || DEFAULT_TIMES; + } else { + throw new Error("Invalid arguments for async.retry"); + } + } + + if (arguments.length < 3 && typeof opts === 'function') { + callback = task || noop; + task = opts; + } else { + parseTimes(options, opts); + callback = callback || noop; + } + + if (typeof task !== 'function') { + throw new Error("Invalid arguments for async.retry"); + } + + var _task = wrapAsync(task); + + var attempt = 1; + function retryAttempt() { + _task(function(err) { + if (err && attempt++ < options.times && + (typeof options.errorFilter != 'function' || + options.errorFilter(err))) { + setTimeout(retryAttempt, options.intervalFunc(attempt)); + } else { + callback.apply(null, arguments); + } + }); + } + + retryAttempt(); +} + +/** + * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method + * wraps a task and makes it retryable, rather than immediately calling it + * with retries. + * + * @name retryable + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.retry]{@link module:ControlFlow.retry} + * @category Control Flow + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional + * options, exactly the same as from `retry` + * @param {AsyncFunction} task - the asynchronous function to wrap. + * This function will be passed any arguments passed to the returned wrapper. + * Invoked with (...args, callback). + * @returns {AsyncFunction} The wrapped function, which when invoked, will + * retry on an error, based on the parameters specified in `opts`. + * This function will accept the same parameters as `task`. + * @example + * + * async.auto({ + * dep1: async.retryable(3, getFromFlakyService), + * process: ["dep1", async.retryable(3, function (results, cb) { + * maybeProcessData(results.dep1, cb); + * })] + * }, callback); + */ +var retryable = function (opts, task) { + if (!task) { + task = opts; + opts = null; + } + var _task = wrapAsync(task); + return initialParams(function (args, callback) { + function taskFn(cb) { + _task.apply(null, args.concat(cb)); + } + + if (opts) retry(opts, taskFn, callback); + else retry(taskFn, callback); + + }); +}; + +/** + * Run the functions in the `tasks` collection in series, each one running once + * the previous function has completed. If any functions in the series pass an + * error to its callback, no more functions are run, and `callback` is + * immediately called with the value of the error. Otherwise, `callback` + * receives an array of results when `tasks` have completed. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function, and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.series}. + * + * **Note** that while many implementations preserve the order of object + * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) + * explicitly states that + * + * > The mechanics and order of enumerating the properties is not specified. + * + * So if you rely on the order in which your series of functions are executed, + * and want this to work on all platforms, consider using an array. + * + * @name series + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection containing + * [async functions]{@link AsyncFunction} to run in series. + * Each function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This function gets a results array (or object) + * containing all the result arguments passed to the `task` callbacks. Invoked + * with (err, result). + * @example + * async.series([ + * function(callback) { + * // do some stuff ... + * callback(null, 'one'); + * }, + * function(callback) { + * // do some more stuff ... + * callback(null, 'two'); + * } + * ], + * // optional callback + * function(err, results) { + * // results is now equal to ['one', 'two'] + * }); + * + * async.series({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback){ + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * // results is now equal to: {one: 1, two: 2} + * }); + */ +function series(tasks, callback) { + _parallel(eachOfSeries, tasks, callback); +} + +/** + * Returns `true` if at least one element in the `coll` satisfies an async test. + * If any iteratee call returns `true`, the main `callback` is immediately + * called. + * + * @name some + * @static + * @memberOf module:Collections + * @method + * @alias any + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @example + * + * async.some(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, result) { + * // if result is true then at least one of the files exists + * }); + */ +var some = doParallel(_createTester(Boolean, identity)); + +/** + * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time. + * + * @name someLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anyLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + */ +var someLimit = doParallelLimit(_createTester(Boolean, identity)); + +/** + * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time. + * + * @name someSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anySeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in series. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + */ +var someSeries = doLimit(someLimit, 1); + +/** + * Sorts a list by the results of running each `coll` value through an async + * `iteratee`. + * + * @name sortBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a value to use as the sort criteria as + * its `result`. + * Invoked with (item, callback). + * @param {Function} callback - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is the items + * from the original `coll` sorted by the values returned by the `iteratee` + * calls. Invoked with (err, results). + * @example + * + * async.sortBy(['file1','file2','file3'], function(file, callback) { + * fs.stat(file, function(err, stats) { + * callback(err, stats.mtime); + * }); + * }, function(err, results) { + * // results is now the original array of files sorted by + * // modified date + * }); + * + * // By modifying the callback parameter the + * // sorting order can be influenced: + * + * // ascending order + * async.sortBy([1,9,3,5], function(x, callback) { + * callback(null, x); + * }, function(err,result) { + * // result callback + * }); + * + * // descending order + * async.sortBy([1,9,3,5], function(x, callback) { + * callback(null, x*-1); //<- x*-1 instead of x, turns the order around + * }, function(err,result) { + * // result callback + * }); + */ +function sortBy (coll, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + map(coll, function (x, callback) { + _iteratee(x, function (err, criteria) { + if (err) return callback(err); + callback(null, {value: x, criteria: criteria}); + }); + }, function (err, results) { + if (err) return callback(err); + callback(null, arrayMap(results.sort(comparator), baseProperty('value'))); + }); + + function comparator(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + } +} + +/** + * Sets a time limit on an asynchronous function. If the function does not call + * its callback within the specified milliseconds, it will be called with a + * timeout error. The code property for the error object will be `'ETIMEDOUT'`. + * + * @name timeout + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} asyncFn - The async function to limit in time. + * @param {number} milliseconds - The specified time limit. + * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) + * to timeout Error for more information.. + * @returns {AsyncFunction} Returns a wrapped function that can be used with any + * of the control flow functions. + * Invoke this function with the same parameters as you would `asyncFunc`. + * @example + * + * function myFunction(foo, callback) { + * doAsyncTask(foo, function(err, data) { + * // handle errors + * if (err) return callback(err); + * + * // do some stuff ... + * + * // return processed data + * return callback(null, data); + * }); + * } + * + * var wrapped = async.timeout(myFunction, 1000); + * + * // call `wrapped` as you would `myFunction` + * wrapped({ bar: 'bar' }, function(err, data) { + * // if `myFunction` takes < 1000 ms to execute, `err` + * // and `data` will have their expected values + * + * // else `err` will be an Error with the code 'ETIMEDOUT' + * }); + */ +function timeout(asyncFn, milliseconds, info) { + var fn = wrapAsync(asyncFn); + + return initialParams(function (args, callback) { + var timedOut = false; + var timer; + + function timeoutCallback() { + var name = asyncFn.name || 'anonymous'; + var error = new Error('Callback function "' + name + '" timed out.'); + error.code = 'ETIMEDOUT'; + if (info) { + error.info = info; + } + timedOut = true; + callback(error); + } + + args.push(function () { + if (!timedOut) { + callback.apply(null, arguments); + clearTimeout(timer); + } + }); + + // setup timer and call original function + timer = setTimeout(timeoutCallback, milliseconds); + fn.apply(null, args); + }); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil; +var nativeMax = Math.max; + +/** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ +function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[fromRight ? length : ++index] = start; + start += step; + } + return result; +} + +/** + * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a + * time. + * + * @name timesLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} count - The number of times to run the function. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see [async.map]{@link module:Collections.map}. + */ +function timeLimit(count, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + mapLimit(baseRange(0, count, 1), limit, _iteratee, callback); +} + +/** + * Calls the `iteratee` function `n` times, and accumulates results in the same + * manner you would use with [map]{@link module:Collections.map}. + * + * @name times + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.map]{@link module:Collections.map} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + * @example + * + * // Pretend this is some complicated async factory + * var createUser = function(id, callback) { + * callback(null, { + * id: 'user' + id + * }); + * }; + * + * // generate 5 users + * async.times(5, function(n, next) { + * createUser(n, function(err, user) { + * next(err, user); + * }); + * }, function(err, users) { + * // we should now have 5 users + * }); + */ +var times = doLimit(timeLimit, Infinity); + +/** + * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time. + * + * @name timesSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + */ +var timesSeries = doLimit(timeLimit, 1); + +/** + * A relative of `reduce`. Takes an Object or Array, and iterates over each + * element in series, each step potentially mutating an `accumulator` value. + * The type of the accumulator defaults to the type of collection passed in. + * + * @name transform + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {*} [accumulator] - The initial state of the transform. If omitted, + * it will default to an empty Object or Array, depending on the type of `coll` + * @param {AsyncFunction} iteratee - A function applied to each item in the + * collection that potentially modifies the accumulator. + * Invoked with (accumulator, item, key, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the transformed accumulator. + * Invoked with (err, result). + * @example + * + * async.transform([1,2,3], function(acc, item, index, callback) { + * // pointless async: + * process.nextTick(function() { + * acc.push(item * 2) + * callback(null) + * }); + * }, function(err, result) { + * // result is now equal to [2, 4, 6] + * }); + * + * @example + * + * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) { + * setImmediate(function () { + * obj[key] = val * 2; + * callback(); + * }) + * }, function (err, result) { + * // result is equal to {a: 2, b: 4, c: 6} + * }) + */ +function transform (coll, accumulator, iteratee, callback) { + if (arguments.length <= 3) { + callback = iteratee; + iteratee = accumulator; + accumulator = isArray(coll) ? [] : {}; + } + callback = once(callback || noop); + var _iteratee = wrapAsync(iteratee); + + eachOf(coll, function(v, k, cb) { + _iteratee(accumulator, v, k, cb); + }, function(err) { + callback(err, accumulator); + }); +} + +/** + * It runs each task in series but stops whenever any of the functions were + * successful. If one of the tasks were successful, the `callback` will be + * passed the result of the successful task. If all tasks fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name tryEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection containing functions to + * run, each function is passed a `callback(err, result)` it must call on + * completion with an error `err` (which can be `null`) and an optional `result` + * value. + * @param {Function} [callback] - An optional callback which is called when one + * of the tasks has succeeded, or all have failed. It receives the `err` and + * `result` arguments of the last attempt at completing the `task`. Invoked with + * (err, results). + * @example + * async.tryEach([ + * function getDataFromFirstWebsite(callback) { + * // Try getting the data from the first website + * callback(err, data); + * }, + * function getDataFromSecondWebsite(callback) { + * // First website failed, + * // Try getting the data from the backup website + * callback(err, data); + * } + * ], + * // optional callback + * function(err, results) { + * Now do something with the data. + * }); + * + */ +function tryEach(tasks, callback) { + var error = null; + var result; + callback = callback || noop; + eachSeries(tasks, function(task, callback) { + wrapAsync(task)(function (err, res/*, ...args*/) { + if (arguments.length > 2) { + result = slice(arguments, 1); + } else { + result = res; + } + error = err; + callback(!err); + }); + }, function () { + callback(error, result); + }); +} + +/** + * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original, + * unmemoized form. Handy for testing. + * + * @name unmemoize + * @static + * @memberOf module:Utils + * @method + * @see [async.memoize]{@link module:Utils.memoize} + * @category Util + * @param {AsyncFunction} fn - the memoized function + * @returns {AsyncFunction} a function that calls the original unmemoized function + */ +function unmemoize(fn) { + return function () { + return (fn.unmemoized || fn).apply(null, arguments); + }; +} + +/** + * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. + * + * @name whilst + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Function} test - synchronous truth test to perform before each + * execution of `iteratee`. Invoked with (). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns undefined + * @example + * + * var count = 0; + * async.whilst( + * function() { return count < 5; }, + * function(callback) { + * count++; + * setTimeout(function() { + * callback(null, count); + * }, 1000); + * }, + * function (err, n) { + * // 5 seconds have passed, n = 5 + * } + * ); + */ +function whilst(test, iteratee, callback) { + callback = onlyOnce(callback || noop); + var _iteratee = wrapAsync(iteratee); + if (!test()) return callback(null); + var next = function(err/*, ...args*/) { + if (err) return callback(err); + if (test()) return _iteratee(next); + var args = slice(arguments, 1); + callback.apply(null, [null].concat(args)); + }; + _iteratee(next); +} + +/** + * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. `callback` will be passed an error and any + * arguments passed to the final `iteratee`'s callback. + * + * The inverse of [whilst]{@link module:ControlFlow.whilst}. + * + * @name until + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {Function} test - synchronous truth test to perform before each + * execution of `iteratee`. Invoked with (). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + */ +function until(test, iteratee, callback) { + whilst(function() { + return !test.apply(this, arguments); + }, iteratee, callback); +} + +/** + * Runs the `tasks` array of functions in series, each passing their results to + * the next in the array. However, if any of the `tasks` pass an error to their + * own callback, the next function is not executed, and the main `callback` is + * immediately called with the error. + * + * @name waterfall + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array of [async functions]{@link AsyncFunction} + * to run. + * Each function should complete with any number of `result` values. + * The `result` values will be passed as arguments, in order, to the next task. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This will be passed the results of the last task's + * callback. Invoked with (err, [results]). + * @returns undefined + * @example + * + * async.waterfall([ + * function(callback) { + * callback(null, 'one', 'two'); + * }, + * function(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * }, + * function(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + * ], function (err, result) { + * // result now equals 'done' + * }); + * + * // Or, with named functions: + * async.waterfall([ + * myFirstFunction, + * mySecondFunction, + * myLastFunction, + * ], function (err, result) { + * // result now equals 'done' + * }); + * function myFirstFunction(callback) { + * callback(null, 'one', 'two'); + * } + * function mySecondFunction(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * } + * function myLastFunction(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + */ +var waterfall = function(tasks, callback) { + callback = once(callback || noop); + if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); + if (!tasks.length) return callback(); + var taskIndex = 0; + + function nextTask(args) { + var task = wrapAsync(tasks[taskIndex++]); + args.push(onlyOnce(next)); + task.apply(null, args); + } + + function next(err/*, ...args*/) { + if (err || taskIndex === tasks.length) { + return callback.apply(null, arguments); + } + nextTask(slice(arguments, 1)); + } + + nextTask([]); +}; + +/** + * An "async function" in the context of Async is an asynchronous function with + * a variable number of parameters, with the final parameter being a callback. + * (`function (arg1, arg2, ..., callback) {}`) + * The final callback is of the form `callback(err, results...)`, which must be + * called once the function is completed. The callback should be called with a + * Error as its first argument to signal that an error occurred. + * Otherwise, if no error occurred, it should be called with `null` as the first + * argument, and any additional `result` arguments that may apply, to signal + * successful completion. + * The callback must be called exactly once, ideally on a later tick of the + * JavaScript event loop. + * + * This type of function is also referred to as a "Node-style async function", + * or a "continuation passing-style function" (CPS). Most of the methods of this + * library are themselves CPS/Node-style async functions, or functions that + * return CPS/Node-style async functions. + * + * Wherever we accept a Node-style async function, we also directly accept an + * [ES2017 `async` function]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function}. + * In this case, the `async` function will not be passed a final callback + * argument, and any thrown error will be used as the `err` argument of the + * implicit callback, and the return value will be used as the `result` value. + * (i.e. a `rejected` of the returned Promise becomes the `err` callback + * argument, and a `resolved` value becomes the `result`.) + * + * Note, due to JavaScript limitations, we can only detect native `async` + * functions and not transpilied implementations. + * Your environment must have `async`/`await` support for this to work. + * (e.g. Node > v7.6, or a recent version of a modern browser). + * If you are using `async` functions through a transpiler (e.g. Babel), you + * must still wrap the function with [asyncify]{@link module:Utils.asyncify}, + * because the `async function` will be compiled to an ordinary function that + * returns a promise. + * + * @typedef {Function} AsyncFunction + * @static + */ + +/** + * Async is a utility module which provides straight-forward, powerful functions + * for working with asynchronous JavaScript. Although originally designed for + * use with [Node.js](http://nodejs.org) and installable via + * `npm install --save async`, it can also be used directly in the browser. + * @module async + * @see AsyncFunction + */ + + +/** + * A collection of `async` functions for manipulating collections, such as + * arrays and objects. + * @module Collections + */ + +/** + * A collection of `async` functions for controlling the flow through a script. + * @module ControlFlow + */ + +/** + * A collection of `async` utility functions. + * @module Utils + */ + +var index = { + apply: apply, + applyEach: applyEach, + applyEachSeries: applyEachSeries, + asyncify: asyncify, + auto: auto, + autoInject: autoInject, + cargo: cargo, + compose: compose, + concat: concat, + concatLimit: concatLimit, + concatSeries: concatSeries, + constant: constant, + detect: detect, + detectLimit: detectLimit, + detectSeries: detectSeries, + dir: dir, + doDuring: doDuring, + doUntil: doUntil, + doWhilst: doWhilst, + during: during, + each: eachLimit, + eachLimit: eachLimit$1, + eachOf: eachOf, + eachOfLimit: eachOfLimit, + eachOfSeries: eachOfSeries, + eachSeries: eachSeries, + ensureAsync: ensureAsync, + every: every, + everyLimit: everyLimit, + everySeries: everySeries, + filter: filter, + filterLimit: filterLimit, + filterSeries: filterSeries, + forever: forever, + groupBy: groupBy, + groupByLimit: groupByLimit, + groupBySeries: groupBySeries, + log: log, + map: map, + mapLimit: mapLimit, + mapSeries: mapSeries, + mapValues: mapValues, + mapValuesLimit: mapValuesLimit, + mapValuesSeries: mapValuesSeries, + memoize: memoize, + nextTick: nextTick, + parallel: parallelLimit, + parallelLimit: parallelLimit$1, + priorityQueue: priorityQueue, + queue: queue$1, + race: race, + reduce: reduce, + reduceRight: reduceRight, + reflect: reflect, + reflectAll: reflectAll, + reject: reject, + rejectLimit: rejectLimit, + rejectSeries: rejectSeries, + retry: retry, + retryable: retryable, + seq: seq, + series: series, + setImmediate: setImmediate$1, + some: some, + someLimit: someLimit, + someSeries: someSeries, + sortBy: sortBy, + timeout: timeout, + times: times, + timesLimit: timeLimit, + timesSeries: timesSeries, + transform: transform, + tryEach: tryEach, + unmemoize: unmemoize, + until: until, + waterfall: waterfall, + whilst: whilst, + + // aliases + all: every, + allLimit: everyLimit, + allSeries: everySeries, + any: some, + anyLimit: someLimit, + anySeries: someSeries, + find: detect, + findLimit: detectLimit, + findSeries: detectSeries, + forEach: eachLimit, + forEachSeries: eachSeries, + forEachLimit: eachLimit$1, + forEachOf: eachOf, + forEachOfSeries: eachOfSeries, + forEachOfLimit: eachOfLimit, + inject: reduce, + foldl: reduce, + foldr: reduceRight, + select: filter, + selectLimit: filterLimit, + selectSeries: filterSeries, + wrapSync: asyncify +}; + +exports['default'] = index; +exports.apply = apply; +exports.applyEach = applyEach; +exports.applyEachSeries = applyEachSeries; +exports.asyncify = asyncify; +exports.auto = auto; +exports.autoInject = autoInject; +exports.cargo = cargo; +exports.compose = compose; +exports.concat = concat; +exports.concatLimit = concatLimit; +exports.concatSeries = concatSeries; +exports.constant = constant; +exports.detect = detect; +exports.detectLimit = detectLimit; +exports.detectSeries = detectSeries; +exports.dir = dir; +exports.doDuring = doDuring; +exports.doUntil = doUntil; +exports.doWhilst = doWhilst; +exports.during = during; +exports.each = eachLimit; +exports.eachLimit = eachLimit$1; +exports.eachOf = eachOf; +exports.eachOfLimit = eachOfLimit; +exports.eachOfSeries = eachOfSeries; +exports.eachSeries = eachSeries; +exports.ensureAsync = ensureAsync; +exports.every = every; +exports.everyLimit = everyLimit; +exports.everySeries = everySeries; +exports.filter = filter; +exports.filterLimit = filterLimit; +exports.filterSeries = filterSeries; +exports.forever = forever; +exports.groupBy = groupBy; +exports.groupByLimit = groupByLimit; +exports.groupBySeries = groupBySeries; +exports.log = log; +exports.map = map; +exports.mapLimit = mapLimit; +exports.mapSeries = mapSeries; +exports.mapValues = mapValues; +exports.mapValuesLimit = mapValuesLimit; +exports.mapValuesSeries = mapValuesSeries; +exports.memoize = memoize; +exports.nextTick = nextTick; +exports.parallel = parallelLimit; +exports.parallelLimit = parallelLimit$1; +exports.priorityQueue = priorityQueue; +exports.queue = queue$1; +exports.race = race; +exports.reduce = reduce; +exports.reduceRight = reduceRight; +exports.reflect = reflect; +exports.reflectAll = reflectAll; +exports.reject = reject; +exports.rejectLimit = rejectLimit; +exports.rejectSeries = rejectSeries; +exports.retry = retry; +exports.retryable = retryable; +exports.seq = seq; +exports.series = series; +exports.setImmediate = setImmediate$1; +exports.some = some; +exports.someLimit = someLimit; +exports.someSeries = someSeries; +exports.sortBy = sortBy; +exports.timeout = timeout; +exports.times = times; +exports.timesLimit = timeLimit; +exports.timesSeries = timesSeries; +exports.transform = transform; +exports.tryEach = tryEach; +exports.unmemoize = unmemoize; +exports.until = until; +exports.waterfall = waterfall; +exports.whilst = whilst; +exports.all = every; +exports.allLimit = everyLimit; +exports.allSeries = everySeries; +exports.any = some; +exports.anyLimit = someLimit; +exports.anySeries = someSeries; +exports.find = detect; +exports.findLimit = detectLimit; +exports.findSeries = detectSeries; +exports.forEach = eachLimit; +exports.forEachSeries = eachSeries; +exports.forEachLimit = eachLimit$1; +exports.forEachOf = eachOf; +exports.forEachOfSeries = eachOfSeries; +exports.forEachOfLimit = eachOfLimit; +exports.inject = reduce; +exports.foldl = reduce; +exports.foldr = reduceRight; +exports.select = filter; +exports.selectLimit = filterLimit; +exports.selectSeries = filterSeries; +exports.wrapSync = asyncify; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(7).setImmediate, __webpack_require__(1), __webpack_require__(2), __webpack_require__(37)(module))) + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {var fs = __webpack_require__(21); +var intelhex = __webpack_require__(22); + +var tools = {}; + +/** + * Opens and parses a given hex file + */ +tools._parseHex = function(file) { + try { + var data; + if (typeof file === 'string') { + data = fs.readFileSync(file, { + encoding: 'utf8' + }); + } else { + // ensure compatibility with browser array buffers + data = Buffer.from(file); + } + + return intelhex.parse(data).data; + } catch (error) { + return error; + } +}; + +tools._hexStringToByte = function(str) { + return Buffer.from([parseInt(str,16)]); +} + +module.exports = tools; + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(0).Buffer)) + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +var Buffer = __webpack_require__(0).Buffer; // for use with browserify + +module.exports = function (a, b) { + if (!Buffer.isBuffer(a)) return undefined; + if (!Buffer.isBuffer(b)) return undefined; + if (typeof a.equals === 'function') return a.equals(b); + if (a.length !== b.length) return false; + + for (var i = 0; i < a.length; i++) { + if (a[i] !== b[i]) return false; + } + + return true; +}; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {var Resp_STK_INSYNC = 0x14; +var Resp_STK_OK = 0x10; + +module.exports = { + Cmnd_STK_GET_SYNC: 0x30, + Cmnd_STK_SET_DEVICE: 0x42, + Cmnd_STK_ENTER_PROGMODE: 0x50, + Cmnd_STK_LOAD_ADDRESS: 0x55, + Cmnd_STK_PROG_PAGE: 0x64, + Cmnd_STK_LEAVE_PROGMODE: 0x51, + Cmnd_STK_READ_SIGN: 0x75, + + Sync_CRC_EOP: 0x20, + + Resp_STK_OK: 0x10, + Resp_STK_INSYNC: 0x14, + Resp_STK_NOSYNC: 0x15, + + + Cmnd_STK_READ_PAGE: 0x74, + + + OK_RESPONSE: new Buffer([Resp_STK_INSYNC, Resp_STK_OK]) +}; + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(0).Buffer)) + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +var colors = __webpack_require__(5); +module['exports'] = colors; + +// Remark: By default, colors will add style properties to String.prototype +// +// If you don't wish to extend String.prototype you can do this instead and native String will not be touched +// +// var colors = require('colors/safe); +// colors.red("foo") +// +// +__webpack_require__(55)(); + +/***/ }), +/* 17 */ +/***/ (function(module, exports) { + +/** + * Generic Protocol for other protocols to inherit from + * + */ +var Protocol = function(options) { + this.debug = options.debug; + + this.board = options.board; + this.connection = options.connection; + + this.chip = new options.protocol({ quiet: true }); +}; + +/** + * Resets an Arduino STK500 bootloaded chip by pulsing DTR high. + * + * Avoids the dreaded timeout bug if the serialport was opened since the device + * was powered. + * + * @param {function} callback - function to run upon completion/error + */ +Protocol.prototype._reset = function(callback) { + var _this = this; + + // cycle DTR/RTS from low to high + _this.connection._cycleDTR(function(error) { + if (!error) { + _this.debug('reset complete.'); + } + + return callback(error); + }); +}; + +module.exports = Protocol; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__(25); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = __webpack_require__(19); +exports.Duplex = __webpack_require__(4); +exports.Transform = __webpack_require__(29); +exports.PassThrough = __webpack_require__(68); + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + + + +/**/ + +var pna = __webpack_require__(10); +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/**/ + +/**/ +var Duplex; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = __webpack_require__(8); +util.inherits = __webpack_require__(3); +/**/ + +/**/ +var internalUtil = { + deprecate: __webpack_require__(67) +}; +/**/ + +/**/ +var Stream = __webpack_require__(26); +/**/ + +/**/ + +var Buffer = __webpack_require__(11).Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +var destroyImpl = __webpack_require__(27); + +util.inherits(Writable, Stream); + +function nop() {} + +function WritableState(options, stream) { + Duplex = Duplex || __webpack_require__(4); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || __webpack_require__(4); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + pna.nextTick(cb, er); +} + +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function () { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; +} + +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + pna.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + pna.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + pna.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} + +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} + +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } +}); + +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1), __webpack_require__(7).setImmediate, __webpack_require__(2))) + +/***/ }), +/* 20 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {//Intel Hex record types +const DATA = 0, + END_OF_FILE = 1, + EXT_SEGMENT_ADDR = 2, + START_SEGMENT_ADDR = 3, + EXT_LINEAR_ADDR = 4, + START_LINEAR_ADDR = 5; + +const EMPTY_VALUE = 0xFF; + +/* intel_hex.parse(data) + `data` - Intel Hex file (string in ASCII format or Buffer Object) + `bufferSize` - the size of the Buffer containing the data (optional) + + returns an Object with the following properties: + - data - data as a Buffer Object, padded with 0xFF + where data is empty. + - startSegmentAddress - the address provided by the last + start segment address record; null, if not given + - startLinearAddress - the address provided by the last + start linear address record; null, if not given + Special thanks to: http://en.wikipedia.org/wiki/Intel_HEX +*/ +exports.parse = function parseIntelHex(data, bufferSize) { + if(data instanceof Buffer) + data = data.toString("ascii"); + //Initialization + var buf = new Buffer(bufferSize || 8192), + bufLength = 0, //Length of data in the buffer + highAddress = 0, //upper address + startSegmentAddress = null, + startLinearAddress = null, + lineNum = 0, //Line number in the Intel Hex string + pos = 0; //Current position in the Intel Hex string + const SMALLEST_LINE = 11; + while(pos + SMALLEST_LINE <= data.length) + { + //Parse an entire line + if(data.charAt(pos++) != ":") + throw new Error("Line " + (lineNum+1) + + " does not start with a colon (:)."); + else + lineNum++; + //Number of bytes (hex digit pairs) in the data field + var dataLength = parseInt(data.substr(pos, 2), 16); + pos += 2; + //Get 16-bit address (big-endian) + var lowAddress = parseInt(data.substr(pos, 4), 16); + pos += 4; + //Record type + var recordType = parseInt(data.substr(pos, 2), 16); + pos += 2; + //Data field (hex-encoded string) + var dataField = data.substr(pos, dataLength * 2), + dataFieldBuf = new Buffer(dataField, "hex"); + pos += dataLength * 2; + //Checksum + var checksum = parseInt(data.substr(pos, 2), 16); + pos += 2; + //Validate checksum + var calcChecksum = (dataLength + (lowAddress >> 8) + + lowAddress + recordType) & 0xFF; + for(var i = 0; i < dataLength; i++) + calcChecksum = (calcChecksum + dataFieldBuf[i]) & 0xFF; + calcChecksum = (0x100 - calcChecksum) & 0xFF; + if(checksum != calcChecksum) + throw new Error("Invalid checksum on line " + lineNum + + ": got " + checksum + ", but expected " + calcChecksum); + //Parse the record based on its recordType + switch(recordType) + { + case DATA: + var absoluteAddress = highAddress + lowAddress; + //Expand buf, if necessary + if(absoluteAddress + dataLength >= buf.length) + { + var tmp = new Buffer((absoluteAddress + dataLength) * 2); + buf.copy(tmp, 0, 0, bufLength); + buf = tmp; + } + //Write over skipped bytes with EMPTY_VALUE + if(absoluteAddress > bufLength) + buf.fill(EMPTY_VALUE, bufLength, absoluteAddress); + //Write the dataFieldBuf to buf + dataFieldBuf.copy(buf, absoluteAddress); + bufLength = Math.max(bufLength, absoluteAddress + dataLength); + break; + case END_OF_FILE: + if(dataLength != 0) + throw new Error("Invalid EOF record on line " + + lineNum + "."); + return { + "data": buf.slice(0, bufLength), + "startSegmentAddress": startSegmentAddress, + "startLinearAddress": startLinearAddress + }; + break; + case EXT_SEGMENT_ADDR: + if(dataLength != 2 || lowAddress != 0) + throw new Error("Invalid extended segment address record on line " + + lineNum + "."); + highAddress = parseInt(dataField, 16) << 4; + break; + case START_SEGMENT_ADDR: + if(dataLength != 4 || lowAddress != 0) + throw new Error("Invalid start segment address record on line " + + lineNum + "."); + startSegmentAddress = parseInt(dataField, 16); + break; + case EXT_LINEAR_ADDR: + if(dataLength != 2 || lowAddress != 0) + throw new Error("Invalid extended linear address record on line " + + lineNum + "."); + highAddress = parseInt(dataField, 16) << 16; + break; + case START_LINEAR_ADDR: + if(dataLength != 4 || lowAddress != 0) + throw new Error("Invalid start linear address record on line " + + lineNum + "."); + startLinearAddress = parseInt(dataField, 16); + break; + default: + throw new Error("Invalid record type (" + recordType + + ") on line " + lineNum); + break; + } + //Advance to the next line + if(data.charAt(pos) == "\r") + pos++; + if(data.charAt(pos) == "\n") + pos++; + } + throw new Error("Unexpected end of input: missing or invalid EOF record."); +}; +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(0).Buffer)) + +/***/ }), +/* 23 */ +/***/ (function(module, exports) { + +function webpackEmptyContext(req) { + var e = new Error("Cannot find module '" + req + "'"); + e.code = 'MODULE_NOT_FOUND'; + throw e; +} +webpackEmptyContext.keys = function() { return []; }; +webpackEmptyContext.resolve = webpackEmptyContext; +module.exports = webpackEmptyContext; +webpackEmptyContext.id = 23; + +/***/ }), +/* 24 */ +/***/ (function(module, exports) { + + +// STK message constants +module.exports.MESSAGE_START = 0x1B +module.exports.TOKEN = 0x0E + +// STK general command constants +module.exports.CMD_SIGN_ON = 0x01 +module.exports.CMD_SET_PARAMETER = 0x02 +module.exports.CMD_GET_PARAMETER = 0x03 +module.exports.CMD_SET_DEVICE_PARAMETERS = 0x04 +module.exports.CMD_OSCCAL = 0x05 +module.exports.CMD_LOAD_ADDRESS = 0x06 +module.exports.CMD_FIRMWARE_UPGRADE = 0x07 + +// STK ISP command constants +module.exports.CMD_ENTER_PROGMODE_ISP = 0x10 +module.exports.CMD_LEAVE_PROGMODE_ISP = 0x11 +module.exports.CMD_CHIP_ERASE_ISP = 0x12 +module.exports.CMD_PROGRAM_FLASH_ISP = 0x13 +module.exports.CMD_READ_FLASH_ISP = 0x14 +module.exports.CMD_PROGRAM_EEPROM_ISP = 0x15 +module.exports.CMD_READ_EEPROM_ISP = 0x16 +module.exports.CMD_PROGRAM_FUSE_ISP = 0x17 +module.exports.CMD_READ_FUSE_ISP = 0x18 +module.exports.CMD_PROGRAM_LOCK_ISP = 0x19 +module.exports.CMD_READ_LOCK_ISP = 0x1A +module.exports.CMD_READ_SIGNATURE_ISP = 0x1B +module.exports.CMD_READ_OSCCAL_ISP = 0x1C +module.exports.CMD_SPI_MULTI = 0x1D + +// STK PP command constants +module.exports.CMD_ENTER_PROGMODE_PP = 0x20 +module.exports.CMD_LEAVE_PROGMODE_PP = 0x21 +module.exports.CMD_CHIP_ERASE_PP = 0x22 +module.exports.CMD_PROGRAM_FLASH_PP = 0x23 +module.exports.CMD_READ_FLASH_PP = 0x24 +module.exports.CMD_PROGRAM_EEPROM_PP = 0x25 +module.exports.CMD_READ_EEPROM_PP = 0x26 +module.exports.CMD_PROGRAM_FUSE_PP = 0x27 +module.exports.CMD_READ_FUSE_PP = 0x28 +module.exports.CMD_PROGRAM_LOCK_PP = 0x29 +module.exports.CMD_READ_LOCK_PP = 0x2A +module.exports.CMD_READ_SIGNATURE_PP = 0x2B +module.exports.CMD_READ_OSCCAL_PP = 0x2C +module.exports.CMD_SET_CONTROL_STACK = 0x2D + +// STK HVSP command constants +module.exports.CMD_ENTER_PROGMODE_HVSP = 0x30 +module.exports.CMD_LEAVE_PROGMODE_HVSP = 0x31 +module.exports.CMD_CHIP_ERASE_HVSP = 0x32 +module.exports.CMD_PROGRAM_FLASH_HVSP = 0x33 +module.exports.CMD_READ_FLASH_HVSP = 0x34 +module.exports.CMD_PROGRAM_EEPROM_HVSP = 0x35 +module.exports.CMD_READ_EEPROM_HVSP = 0x36 +module.exports.CMD_PROGRAM_FUSE_HVSP = 0x37 +module.exports.CMD_READ_FUSE_HVSP = 0x38 +module.exports.CMD_PROGRAM_LOCK_HVSP = 0x39 +module.exports.CMD_READ_LOCK_HVSP = 0x3A +module.exports.CMD_READ_SIGNATURE_HVSP = 0x3B +module.exports.CMD_READ_OSCCAL_HVSP = 0x3C + +// STK status constants +// Success +module.exports.STATUS_CMD_OK = 0x00 +// Warnings +module.exports.STATUS_CMD_TOUT = 0x80 +module.exports.STATUS_RDY_BSY_TOUT = 0x81 +module.exports.STATUS_SET_PARAM_MISSING = 0x82 +// Errors +module.exports.STATUS_CMD_FAILED = 0xC0 +module.exports.STATUS_CKSUM_ERROR = 0xC1 +module.exports.STATUS_CMD_UNKNOWN = 0xC9 + +// STK parameter constants +module.exports.STATUS_BUILD_NUMBER_LOW = 0x80 +module.exports.STATUS_BUILD_NUMBER_HIGH = 0x81 +module.exports.STATUS_HW_VER = 0x90 +module.exports.STATUS_SW_MAJOR = 0x91 +module.exports.STATUS_SW_MINOR = 0x92 +module.exports.STATUS_VTARGET = 0x94 +module.exports.STATUS_VADJUST = 0x95 +module.exports.STATUS_OSC_PSCALE = 0x96 +module.exports.STATUS_OSC_CMATCH = 0x97 +module.exports.STATUS_SCK_DURATION = 0x98 +module.exports.STATUS_TOPCARD_DETECT = 0x9A +module.exports.STATUS_STATUS = 0x9C +module.exports.STATUS_DATA = 0x9D +module.exports.STATUS_RESET_POLARITY = 0x9E +module.exports.STATUS_CONTROLLER_INIT = 0x9F + +// STK answer constants +module.exports.ANSWER_CKSUM_ERROR = 0xB0 + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +/**/ + +var pna = __webpack_require__(10); +/**/ + +module.exports = Readable; + +/**/ +var isArray = __webpack_require__(20); +/**/ + +/**/ +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; + +/**/ +var EE = __webpack_require__(6).EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream = __webpack_require__(26); +/**/ + +/**/ + +var Buffer = __webpack_require__(11).Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +/**/ +var util = __webpack_require__(8); +util.inherits = __webpack_require__(3); +/**/ + +/**/ +var debugUtil = __webpack_require__(64); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var BufferList = __webpack_require__(65); +var destroyImpl = __webpack_require__(27); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream) { + Duplex = Duplex || __webpack_require__(4); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = __webpack_require__(28).StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || __webpack_require__(4); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = __webpack_require__(28).StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + pna.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this, unpipeInfo); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + pna.nextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._readableState.highWaterMark; + } +}); + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; +} + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + pna.nextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(2), __webpack_require__(1))) + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(6).EventEmitter; + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/**/ + +var pna = __webpack_require__(10); +/**/ + +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); + } + return this; + } + + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; + } + + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); + + return this; +} + +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} + +function emitErrorNT(self, err) { + self.emit('error', err); +} + +module.exports = { + destroy: destroy, + undestroy: undestroy +}; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +/**/ + +var Buffer = __webpack_require__(11).Buffer; +/**/ + +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; + +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; + +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} + +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; + +StringDecoder.prototype.end = utf8End; + +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; + +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; + +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} + +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} + +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } +} + +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} + +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} + +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} + +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} + +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); +} + +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} + +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} + +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + + + +module.exports = Transform; + +var Duplex = __webpack_require__(4); + +/**/ +var util = __webpack_require__(8); +util.inherits = __webpack_require__(3); +/**/ + +util.inherits(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } + + ts.writechunk = null; + ts.writecb = null; + + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + + cb(er); + + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); +} + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +var boards = __webpack_require__(31); +var Connection = __webpack_require__(34); +var protocols = __webpack_require__(41); +var AvrgirlArduino = __webpack_require__(74); + +module.exports = AvrgirlArduino(boards, Connection, protocols); + + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {var boards = [ + { + name: 'uno', + baud: 115200, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0x0043', '0x7523', '0x0001', '0xea60'], + productPage: 'https://store.arduino.cc/arduino-uno-rev3', + protocol: 'stk500v1' + }, + { + name: 'micro', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x0037', '0x8037', '0x0036', '0x0237'], + productPage: 'https://store.arduino.cc/arduino-micro', + protocol: 'avr109' + }, + { + name: 'imuduino', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x0036', '0x8037', '0x8036'], + productPage: 'https://www.kickstarter.com/projects/1265095814/imuduino-wireless-3d-motion-html-js-apps-arduino-p?lang=de', + protocol: 'avr109' + }, + { + name: 'leonardo', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x0036', '0x8036', '0x800c'], + productPage: 'https://store.arduino.cc/leonardo', + protocol: 'avr109' + }, + { + name: 'arduboy', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x0036', '0x8036', '0x800c'], + productPage: 'https://arduboy.com/', + protocol: 'avr109' + }, + { + name: 'feather', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x800c', '0x000c'], + productPage: 'https://www.adafruit.com/feather', + protocol: 'avr109' + }, + { + name: 'little-bits', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x0036', '0x8036'], + productPage: 'https://littlebits.com/collections/bits-and-accessories/products/arduino-bit', + protocol: 'avr109' + }, + { + name: 'blend-micro', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x2404'], + productPage: 'https://redbear.cc/product/retired/blend-micro.html', + protocol: 'avr109' + }, + { + name: 'nano', + baud: 57600, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0x6001', '0x7523'], + productPage: 'https://web.archive.org/web/20150813095112/https://www.arduino.cc/en/Main/ArduinoBoardNano', + protocol: 'stk500v1' + }, + { + name: 'nano (new bootloader)', + baud: 115200, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0x6001', '0x7523'], + productPage: 'https://store.arduino.cc/arduino-nano', + protocol: 'stk500v1' + }, + { + name: 'duemilanove168', + baud: 19200, + signature: new Buffer([0x1e, 0x94, 0x06]), + pageSize: 128, + numPages: 128, + timeout: 400, + productId: ['0x6001'], + productPage: 'https://www.arduino.cc/en/Main/arduinoBoardDuemilanove', + protocol: 'stk500v1' + }, + { + name: 'duemilanove328', + baud: 57600, + signature: new Buffer([0x1e, 0x95, 0x14]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0x6001'], + productPage: 'https://www.arduino.cc/en/Main/arduinoBoardDuemilanove', + protocol: 'stk500v1' + }, + // the alias is here because of an accidental naming change of the tinyduino + // keeping in for backwards compatibility (SHA 05d65842) + { + name: 'tinyduino', + baud: 57600, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0x6015'], + productPage: 'https://tinycircuits.com/pages/tinyduino-overview', + protocol: 'stk500v1', + aliases: ['tinduino'] + }, + { + name: 'mega', + baud: 115200, + signature: new Buffer([0x1e, 0x98, 0x01]), // ATmega2560 + pageSize: 256, + delay1: 10, + delay2: 1, + timeout:0xc8, + stabDelay:0x64, + cmdexeDelay:0x19, + synchLoops:0x20, + byteDelay:0x00, + pollValue:0x53, + pollIndex:0x03, + productId: ['0x0042', '0x6001', '0x0010', '0x7523'], + productPage: 'https://store.arduino.cc/mega-2560-r3', + protocol: 'stk500v2' + }, + { + name: 'adk', + baud: 115200, + signature: new Buffer([0x1e, 0x98, 0x01]), // ATmega2560 + pageSize: 256, + delay1: 10, + delay2: 1, + timeout:0xc8, + stabDelay:0x64, + cmdexeDelay:0x19, + synchLoops:0x20, + byteDelay:0x00, + pollValue:0x53, + pollIndex:0x03, + productId: ['0x0044', '0x6001', '0x003F'], + productPage: 'https://store.arduino.cc/arduino-mega-adk-rev3', + protocol: 'stk500v2' + }, + { + name: 'sf-pro-micro', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x9206', '0x9205'], + productPage: 'https://www.sparkfun.com/products/12640', + protocol: 'avr109' + }, + { + name: 'pro-mini', + baud: 57600, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productPage: 'https://store.arduino.cc/arduino-pro-mini', + protocol: 'stk500v1' + }, + { + name: 'qduino', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x516d', '0x514d'], + productPage: 'https://www.sparkfun.com/products/13614', + protocol: 'avr109' + }, + { + name: 'pinoccio', + baud: 115200, + signature: new Buffer([0x1e, 0xa8, 0x02]), // ATmega256RFR2 + pageSize: 256, + delay1: 10, + delay2: 1, + timeout:0xc8, + stabDelay:0x64, + cmdexeDelay:0x19, + synchLoops:0x20, + byteDelay:0x00, + pollValue:0x53, + pollIndex:0x03, + productId: ['0x6051'], + productPage: 'https://www.mouser.de/new/crowd-supply/crowd-supply-pinoccio-microcontroller/', + protocol: 'stk500v2' + }, + { + name: 'lilypad-usb', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x9207', '0x9208', '0x1B4F'], + productPage: 'https://www.sparkfun.com/products/12049', + protocol: 'avr109' + }, + { + name: 'yun', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x0041', '0x8041'], + productPage: 'https://store.arduino.cc/arduino-yun', + protocol: 'avr109' + }, + { + name: 'esplora', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x003C', '0x803C'], + productPage: 'https://store.arduino.cc/arduino-esplora', + protocol: 'avr109' + }, + { + name: 'circuit-playground-classic', + baud: 57600, + signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]), + productId: ['0x0011', '0x8011'], + productPage: 'https://www.adafruit.com/product/3000', + protocol: 'avr109' + }, + /** BQ - Arduino Based Boards. Used in Bitbloq -> bitbloq.bq.com and Arduino IDE*/ + { + name: 'zumjunior', + baud: 115200, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0xEA60'], + productPage: 'https://store-de.bq.com/de/zum-kit-junior', + protocol: 'stk500v1' + }, + { + name: 'zumcore2', + baud: 115200, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0xEA60'], + productPage: 'https://www.bq.com/de/zum-core-2-0', + protocol: 'stk500v1' + }, + { + name: 'bqZum', + baud: 19200, + signature: new Buffer([0x1e, 0x95, 0x0f]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0x6001', '0x7523'], + productPage: 'http://diwo.bq.com/zum-bt-328-especificaciones-tecnicas/', + protocol: 'stk500v1' + }, + /** END OF BQ - Arduino Based Boards. Used in Bitbloq -> bitbloq.bq.com and Arduino IDE*/ + + /** START OF Spark Concepts Boards - Arduino Based CNC Controller but uses Atmega328pb (Note 'pb' not 'p' = different signature) https://github.com/Spark-Concepts/xPro-V4 */ + { + name: 'xprov4', + baud: 115200, + signature: new Buffer([0x1e, 0x95, 0x16]), + pageSize: 128, + numPages: 256, + timeout: 400, + productId: ['0x0043', '0x7523', '0x0001', '0xea60'], + productPage: 'http://www.spark-concepts.com/cnc-xpro-v4-controller/', + protocol: 'stk500v1' + }, +]; + +/** + * Generate an object with board name keys for faster lookup + * @return {object} byBoardName + */ +function boardLookupTable() { + var byBoard = {}; + for (var i = 0; i < boards.length; i++) { + var currentBoard = boards[i]; + byBoard[currentBoard.name] = currentBoard; + + var aliases = currentBoard.aliases; + if (Array.isArray(aliases)) { + for (var j = 0; j < aliases.length; j++) { + var currentAlias = aliases[j]; + byBoard[currentAlias] = currentBoard; + } + } + } + return byBoard; +} + +module.exports = boardLookupTable(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(0).Buffer)) + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +var Serialport = __webpack_require__(35); +var async = __webpack_require__(12); +var awty = __webpack_require__(38); +var tools = __webpack_require__(13); + +var Connection = function(options) { + this.options = options; + this.debug = this.options.debug ? console.log.bind(console) : function() {}; + + this.board = this.options.board; +}; + +Connection.prototype._init = function(callback) { + this._setUpSerial(function(error) { + return callback(error); + }); +}; + +/** + * Create new serialport instance for the Arduino board, but do not immediately connect. + */ +Connection.prototype._setUpSerial = function(callback) { + this.serialPort = new Serialport('', { + baudRate: this.board.baud, + autoOpen: false + }); + return callback(null); +}; + +/** + * Finds a list of available USB ports, and matches for the right pid + * Auto finds the correct port for the chosen Arduino + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._sniffPort = function(callback) { + var _this = this; + var pidList = _this.board.productId.map(function(id) { + return parseInt(id, 16); + }); + + _this._listPorts(function(error, ports) { + // filter for a match by product id + var portMatch = ports.filter(function(p) { + return pidList.indexOf(parseInt(p._standardPid, 16)) !== -1; + }); + + return callback(null, portMatch); + }); +}; + +/** + * Sets the DTR/RTS lines to either true or false + * + * @param {boolean} bool - value to set DTR and RTS to + * @param {number} timeout - number in milliseconds to delay after + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._setDTR = function(bool, timeout, callback) { + var _this = this; + var props = { + rts: bool, + dtr: bool + }; + + _this.serialPort.set(props, function(error) { + if (error) { return callback(error); } + + setTimeout(function() { + callback(error); + }, timeout); + }); +}; + +/** + * Checks the list of ports 4 times for a device to show up + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._pollForPort = function(callback) { + var _this = this; + + var poll = awty(function(next) { + var found = false; + + // try to sniff port instead (for port hopping devices) + _this._sniffPort(function(error, port) { + if (port.length) { + // found a port, save it + _this.options.port = port[0].comName; + found = true; + } + + next(found); + }); + }); + + poll.every(100).ask(15); + + poll(function(foundPort) { + if (foundPort) { + _this.debug('found port on', _this.options.port); + // set up serialport for it + _this._setUpSerial(function(error) { + return callback(error); + }); + } else { + // we also could not find the device on auto sniff + return callback(new Error('could not reconnect after resetting board.')); + } + }); +}; + +Connection.prototype._pollForOpen = function(callback) { + var _this = this; + + var poll = awty(function(next) { + _this.serialPort.open(function(error) { + next(!error); + }); + }); + + poll.every(200).ask(10); + + poll(function(isOpen) { + var error; + if (!isOpen) { + error = new Error('could not open board on ' + _this.serialPort.path); + } + + callback(error); + }); +}; + +/** + * Pulse the DTR/RTS lines low then high + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._cycleDTR = function(callback) { + var _this = this; + + async.series([ + _this._setDTR.bind(_this, true, 250), + _this._setDTR.bind(_this, false, 50) + ], + function(error) { + return callback(error); + }); + +}; + +/** + * Return a list of devices on serial ports. In addition to the output provided + * by SerialPort.list, it adds a platform independent PID in _pid + * + * @param {function} callback - function to run upon completion/error + */ +Connection.prototype._listPorts = function(callback) { + var foundPorts = []; + + // list all available ports + Serialport.list(function(err, ports) { + if (err) { return callback(err); } + + // iterate through ports + for (var i = 0; i < ports.length; i += 1) { + var pid; + + // are we on windows or unix? + // TODO: this can be simplified as Chrome will likely give us a consistent set of props across each OS + if (ports[i].productId) { + pid = ports[i].productId; + } else if (ports[i].pnpId) { + try { + pid = '0x' + /PID_\d*/.exec(ports[i].pnpId)[0].substr(4); + } catch (err) { + pid = ''; + } + } else { + pid = ''; + } + + // TODO: find out if returned ports are immutable + ports[i]._standardPid = pid; + foundPorts.push(ports[i]); + } + + return callback(null, foundPorts); + }); +}; + +module.exports = Connection; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {const { EventEmitter } = __webpack_require__(6); + +class SerialPort extends EventEmitter { + constructor(port, options) { + super(options); + this.options = options || {}; + + this.browser = true; + this.path = this.options.path; + this.isOpen = false; + this.port = null; + this.writer = null; + this.reader = null; + this.baudrate = this.options.baudRate; + this.requestOptions = this.options.requestOptions || {}; + + if (this.options.autoOpen) this.open(); + } + + list(callback) { + navigator.serial.getPorts() + .then((list) => callback(null, list)) + .catch((error) => callback(error)); + } + + open(callback) { + navigator.serial.requestPort(this.requestOptions) + .then(serialPort => { + this.port = serialPort; + return this.port.open({ baudrate: this.baudrate || 57600 }); + }) + .then(() => this.writer = this.port.writable.getWriter()) + .then(() => this.reader = this.port.readable.getReader()) + .then(async () => { + this.emit('open'); + this.isOpen = true; + callback(null); + while (this.port.readable) { + try { + while (true) { + const { value, done } = await this.reader.read(); + if (done) { + break; + } + this.emit('data', Buffer.from(value)); + } + } catch (e) { + console.log('ERROR while reading port:', e); + } + } + }) + .catch(error => {callback(error)}); + } + + close(callback) { + this.port.close(); + this.isOpen = false; + if (callback) return callback(null); + } + + set(props, callback) { + this.port.setSignals(props) + .then(() => callback(null)) + .catch((error) => callback(error)); + } + + write(buffer, callback) { + this.writer.write(buffer); + if (callback) return callback(null); + } + + read(callback) { + this.reader.read() + .then((buffer) => callback(null, buffer)) + .catch((error) => callback(error)); + } + + // TODO: is this correct? + flush(callback) { + //this.port.flush(); + if (callback) return callback(null); + } + + drain(callback) { + if (callback) return callback(null); + } +} + +module.exports = SerialPort; + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(0).Buffer)) + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { + "use strict"; + + if (global.setImmediate) { + return; + } + + var nextHandle = 1; // Spec says greater than zero + var tasksByHandle = {}; + var currentlyRunningATask = false; + var doc = global.document; + var registerImmediate; + + function setImmediate(callback) { + // Callback can either be a function or a string + if (typeof callback !== "function") { + callback = new Function("" + callback); + } + // Copy function arguments + var args = new Array(arguments.length - 1); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i + 1]; + } + // Store and register the task + var task = { callback: callback, args: args }; + tasksByHandle[nextHandle] = task; + registerImmediate(nextHandle); + return nextHandle++; + } + + function clearImmediate(handle) { + delete tasksByHandle[handle]; + } + + function run(task) { + var callback = task.callback; + var args = task.args; + switch (args.length) { + case 0: + callback(); + break; + case 1: + callback(args[0]); + break; + case 2: + callback(args[0], args[1]); + break; + case 3: + callback(args[0], args[1], args[2]); + break; + default: + callback.apply(undefined, args); + break; + } + } + + function runIfPresent(handle) { + // From the spec: "Wait until any invocations of this algorithm started before this one have completed." + // So if we're currently running a task, we'll need to delay this invocation. + if (currentlyRunningATask) { + // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a + // "too much recursion" error. + setTimeout(runIfPresent, 0, handle); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunningATask = true; + try { + run(task); + } finally { + clearImmediate(handle); + currentlyRunningATask = false; + } + } + } + } + + function installNextTickImplementation() { + registerImmediate = function(handle) { + process.nextTick(function () { runIfPresent(handle); }); + }; + } + + function canUsePostMessage() { + // The test against `importScripts` prevents this implementation from being installed inside a web worker, + // where `global.postMessage` means something completely different and can't be used for this purpose. + if (global.postMessage && !global.importScripts) { + var postMessageIsAsynchronous = true; + var oldOnMessage = global.onmessage; + global.onmessage = function() { + postMessageIsAsynchronous = false; + }; + global.postMessage("", "*"); + global.onmessage = oldOnMessage; + return postMessageIsAsynchronous; + } + } + + function installPostMessageImplementation() { + // Installs an event handler on `global` for the `message` event: see + // * https://developer.mozilla.org/en/DOM/window.postMessage + // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages + + var messagePrefix = "setImmediate$" + Math.random() + "$"; + var onGlobalMessage = function(event) { + if (event.source === global && + typeof event.data === "string" && + event.data.indexOf(messagePrefix) === 0) { + runIfPresent(+event.data.slice(messagePrefix.length)); + } + }; + + if (global.addEventListener) { + global.addEventListener("message", onGlobalMessage, false); + } else { + global.attachEvent("onmessage", onGlobalMessage); + } + + registerImmediate = function(handle) { + global.postMessage(messagePrefix + handle, "*"); + }; + } + + function installMessageChannelImplementation() { + var channel = new MessageChannel(); + channel.port1.onmessage = function(event) { + var handle = event.data; + runIfPresent(handle); + }; + + registerImmediate = function(handle) { + channel.port2.postMessage(handle); + }; + } + + function installReadyStateChangeImplementation() { + var html = doc.documentElement; + registerImmediate = function(handle) { + // Create a - - - diff --git a/lib/browser-serialport.js b/lib/browser-serialport.js index b0c4087..d4f37ff 100644 --- a/lib/browser-serialport.js +++ b/lib/browser-serialport.js @@ -1,3 +1,4 @@ +// TODO: switch out this browser shim for mitt: https://github.com/developit/mitt const { EventEmitter } = require('events'); class SerialPort extends EventEmitter { @@ -18,15 +19,16 @@ class SerialPort extends EventEmitter { } list(callback) { - navigator.serial.getPorts() - .then((list) => callback(null, list)) - .catch((error) => callback(error)); + return navigator.serial.getPorts() + .then((list) => {if (callback) {return callback(null, list)}}) + .catch((error) => {if (callback) {return callback(error)}}); } open(callback) { navigator.serial.requestPort(this.requestOptions) .then(serialPort => { this.port = serialPort; + if (this.isOpen) return; return this.port.open({ baudrate: this.baudrate || 57600 }); }) .then(() => this.writer = this.port.writable.getWriter()) @@ -35,33 +37,42 @@ class SerialPort extends EventEmitter { this.emit('open'); this.isOpen = true; callback(null); - while (this.port.readable) { - try { - while (true) { - const { value, done } = await this.reader.read(); - if (done) { - break; - } - this.emit('data', Buffer.from(value)); + try { + while (this.port.readable.locked) { + const { value, done } = await this.reader.read(); + if (done) { + break; } - } catch (e) { - console.log('ERROR while reading port:', e); + this.emit('data', Buffer.from(value)); } + } catch (e) { + throw e; } - }) - .catch(error => {callback(error)}); + }) + .catch(error => {callback(error)}); } - close(callback) { - this.port.close(); - this.isOpen = false; - if (callback) return callback(null); + async close(callback) { + try { + await this.reader.releaseLock(); + await this.writer.releaseLock(); + await this.port.close(); + this.isOpen = false; + } catch (error) { + if (callback) return callback(error); + throw error; + } + callback && callback(null); } - set(props, callback) { - this.port.setSignals(props) - .then(() => callback(null)) - .catch((error) => callback(error)); + async set(props, callback) { + try { + await this.port.setSignals(props); + } catch (error) { + if (callback) return callback(error); + throw error; + } + if (callback) return callback(null); } write(buffer, callback) { @@ -69,19 +80,27 @@ class SerialPort extends EventEmitter { if (callback) return callback(null); } - read(callback) { - this.reader.read() - .then((buffer) => callback(null, buffer)) - .catch((error) => callback(error)); + async read(callback) { + try { + const buffer = await this.reader.read(); + } catch (error) { + if (callback) return callback(error); + throw error; + } + if (callback) callback(null, buffer); } // TODO: is this correct? flush(callback) { - //this.port.flush(); + //this.port.flush(); // is this sync or a promise? + console.warn('flush method is a NOP right now'); if (callback) return callback(null); } + // TODO: is this correct? drain(callback) { + // this.port.drain(); // is this sync or a promise? + console.warn('drain method is a NOP right now'); if (callback) return callback(null); } } diff --git a/lib/connection-browser.js b/lib/connection-browser.js index 386c7d4..d7061bd 100644 --- a/lib/connection-browser.js +++ b/lib/connection-browser.js @@ -20,10 +20,14 @@ Connection.prototype._init = function(callback) { * Create new serialport instance for the Arduino board, but do not immediately connect. */ Connection.prototype._setUpSerial = function(callback) { + var _this = this; this.serialPort = new Serialport('', { baudRate: this.board.baud, autoOpen: false }); + this.serialPort.on('open', function() { +// _this.emit('connection:open'); + }) return callback(null); }; @@ -59,7 +63,7 @@ Connection.prototype._sniffPort = function(callback) { Connection.prototype._setDTR = function(bool, timeout, callback) { var _this = this; var props = { - rts: bool, + rts: false, dtr: bool }; diff --git a/package.json b/package.json index 4e5db05..76e7b95 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "module": "dist/avrgirl-arduino.min.js", "scripts": { "test": "gulp test", - "cover": "istanbul cover ./tests/*.spec.js && istanbul-coveralls" + "cover": "istanbul cover ./tests/*.spec.js && istanbul-coveralls", + "build-browser": "webpack -p", + "dev-browser": "webpack --watch" }, "repository": { "type": "git", diff --git a/tests/demos/webserial/favicon.ico b/tests/demos/webserial/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/tests/demos/webserial/images/ArduinoUno.svg b/tests/demos/webserial/images/ArduinoUno.svg new file mode 100644 index 0000000..b0a9f1b --- /dev/null +++ b/tests/demos/webserial/images/ArduinoUno.svg @@ -0,0 +1,10093 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + layer 21 + + + text:MADE IN + + + text:ITALY + + + text:Prototype + + + text:Limited + + + text:Edition + + + + + + + + + + + + + + + + + + + + + + + + + 13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:L + + text:L + + + + + + + + + + L + + + + + + + + + + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + + + + layer 25 + + + + + + + + 5V + + + + + + + + + text:A0 + + + + + + + + + + A0 + + + + + + + + + + + + + + + + + + + + + + ANALOG IN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AREF + + + + + + + + + + + + + + + + + + + + + + + + + text:1 + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + + + + + + text:M.Banzi + + + text:D.Cuartielles + + + text:D.Mellis + + + text:TX + + + + + + + + + + TX + + + + + + + + + + + + text:RX + + + + + + + + + + RX + + + + + + + + + + + + text:G.Martino + + + text:T.Igoe + + + + + + + + + + + + + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3V3 + + + + + + + + + + + + + + + + + + + + + + + + + text:A1 + + + + + + A1 + + + + + + + + text:A2 + + + + + + + + + + A2 + + + + + + + + + + + + text:A3 + + + + + + + + + + A3 + + + + + + + + + + + + text:A4 + + + + + + + + + + A4 + + + + + + + + + + + + text:A5 + + + + + + + + + + A5 + + + + + + + + + + + + + + + + + + + + + + VIN + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + text:[#=PWM] + + + + + + + + + + DIGITAL (PWM= + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:Arduino + + + + + + + + + + Arduino + + + + + + + + + + + + text:TM + + + + + + + + + + TM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IOREF + + + + + + + + + + + + + + + + + + + + + + + + + text:SDA + + + text:SCL + + + element:AD + + package:1X06 + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:D1 + + package:SMB + + + + element:D2 + + package:MINIMELF + + + + element:D3 + + package:MINIMELF + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:ICSP + + text:ICSP + + + + + + + + + + + + + + + + + + + + + + ICSP + + + + + + + + + + + + + + + + + + + + + + + + package:2X03 + + + + element:ICSP + + text:ICSP + + + + + + + + + + + + + + + + + + + + + + ICSP2 + + + + + + + + + + + + + + + + + + + + + + + + package:2X03 + + + + element:ICSP1 + + package:2X03 + + + + element:IOH + + package:1X10@1 + + + + element:IOL + + package:1X08 + + + + element:JP2 + + package:2X02 + + + + element:L + + package:CHIP-LED0805 + + + + element:L1 + + package:0805 + + + + element:ON + + text:ON + + + + + + ON + + + + + + + + package:CHIP-LED0805 + + + + element:PC1 + + package:PANASONIC_D + + + + element:PC2 + + package:PANASONIC_D + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RESET + + package:TS42 + + + + element:RESET-EN + + package:SJ + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:RX + + package:CHIP-LED0805 + + + + element:T1 + + package:SOT-23 + + + + element:TX + + package:CHIP-LED0805 + + + + element:U1 + + package:SOT223 + + + + element:U2 + + package:SOT23-DBV + + + + element:U3 + + package:MLF32 + + + + element:U5 + + package:MSOP08 + + + + element:X1 + + package:POWERSUPPLY_DC-21MM + + + + element:X2 + + package:PN61729 + + + + element:Y1 + + package:QS + + + + element:Y2 + + package:RESONATOR + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + + + element:ZU4 + + package:DIL28-3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + POWER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TX0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RX0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:RESET + + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/demos/webserial/images/gear.idraw b/tests/demos/webserial/images/gear.idraw new file mode 100644 index 0000000000000000000000000000000000000000..ae92eff42069db0cc3d51d8c4664071d7a695f2e GIT binary patch literal 12089 zcmbVy1#sTHw(S>YW@ct?n3}hMBQxn3IN?85-t>nVFL>eAEBDbMDNY_h#XaP2-?;rJ|Q5h+Mi7-_k_1I8k)nMgXumV9;PUmA3! zuHqFs3>Pmd$#LZiIu$#i3zzN}@q3fuDJ8Z0tzRcQENSs$3Tjw;fDk{@k%NbYLOS+nhJncO9+bmRX`|3j5LW^8rM@-cR;H6>2PYdjqlHlkM=XWD9A z8^=xy7V32}a5cn!Vm%A2^VK_^BWPEfxSu5_t+qOEbR5T|s5dg4nh|NXvhtL4I9WE> zT~uU@4p}(&9@V3pW|yc-wXITDVBtljft(355Kf}J-hyp56485Fcx0($@ zW=KHtT2)Y=7ZHCkXdC#{4a&{Jsp#6LBsMuNu8}JxjB)>i_zv_lh zr=~xkEJmfNZi`6GlCNtR#LT6>NPc9SQWQxZU(;NC&BPcf28%?ts9}pmVI%q{v4&(m z9CgeAVN6^G?pHqVwy;Q#7imaH=b9lZCg*Xb5?2SXNqxPpBHVcO^A;!EsW>X-xNxf(Na8 zv%e&^+-r#XC&I6+#O6uh50E!}sS&qmPmNvHLICr;Q0B;2+=*R?UV>p?m_Y!Y(`B&n zG75`IJ0>;@t!z2Lpw;XLCCcrMZ4#X(GYxU%@J6NakVf=Ezo%838KN9lUSV0S2$zI9 z3k0#NSbK@=ghh=BpX~iQ8!TPh{N~>bZJ|%`iavz(vXdB?^J{IrY%SS}wTtX{gIqZt z5B~9Pur+|GBw^Mz5c>?fWs@8-UwqFYa4vqy@@?jO6gigA#W&?^q7e>Zshyhp6g1rh zTAR1z1BWK)9KOVOOil`HdbD7ah#AtrxiKgfiWN-jx$P^f-0pMrpE~)$7p=ATNGLqB zH2$G(mGE4befjwI zOh$A~71;F~pG}=^lhZ8_>&GrEWVB+m+$vUzSRS3B2m0qL${xQs4=p52A>*qj@ ziq-f)t>;`~Q~|&u_$E2SD7gCkeIb5g=YBjkbzveZSzpZW;@`rCal}Sp3oR4TWHu5i z{i|1VZdt)K$m7?vBoxUaPR!q+;0S+_Ote7;m@H8)!;R+i6cX$9<5Nl{MOsPEEaIo- z%dSVjc(QmdffsAKZClu4#ygS9ctTVyD5?*>g^zK|v!WgEKefN&eMQrkRqKruA7Yjk z#2<3KqLSHGrV`LWRzX{rJeH2{bBfpqx=NZcL`8RK`Bi|CVOVWRqPYrGO6!Y2&I~Gb zhKD96kRu@x-yd`+g@K5YDyr`%9<&F`!$3Tsu-$bBmJQQwIl&kqJN8paJTcONCiHp0 zXicD4#bCO?HW~B8+odp@nZpOvwakV3BWtwnIY;5jiAp9k&wS|%5ThlDg=ooalxHLP zfz7d_Dc1rI$SrP&5Eo-fPY=bhAr3tp-~*L4nrM)>2%StiBsqc>;D`X7r&<9|AK(eW z9z$U`l3@aYu;Kb)6M?=SW>D1Qhxev z%%m3f2$How?uc;jL89U4PzK;+#2Hr1P#LtN`6;l*;7F>kbQGn6Znazp3)P9gBL^gG z$@N<1kDLLilU6Qg9>52owR=;dP|t*4Lek}5q6tyzAX?YQcJVV;3X*&X_>NrB8raxX zHoH@*A}Zliz=cI5Bg6OO ziyI1=*TN~+xp}uyY{cJE%E^&UdcY*8C$@%Y8d%B{>FfoWFBQQpLhwL5+HaP$9dMZ_ zL~-E7yM<%XDbHZI6ZelLEXNo$qZ)5Yr8FA9!R&~}FcL@_V?zRhe^7~nH~o;o1kH!> zFyZ=+N<{%J|D9~w8JdmWpKN&qovjMc`v zBCqEt4pWrU1e;gZt(hs-Z#v(8(?wvu)rvL*v4zTKNF12GlNn>=rRwt!w3{G|0$9ft zEORK@!o7+eK*jyzSA|d_=M{3q2;}Hi8rrZ@aN37XzfuY{d;>@1=WK}W2t*zarThx2 zUqMW0_*^i9z$@ZQPff6zl$9G&>@w(JUpzNk+I%s{ia$T~tRxj)VsNY#^+Twp2dluS zX~;2ken&*;h;(97!FZ_TMsTMv(k=%5c>+cOUjA_wg^bD(bvRu(``aIAZ z@h#NO`aebK$W;mbJ9Z?Z|*!{n6Q`4^2Iy*u5w?W}_3C>%iZ?WO0BMPT10S zLYJ`A%xX;oFlSGtv1P`P)tZpoD6CkyM~@qQ_9RijYh)>0 zAT+?8iGLaLYq-FMZm5b(P5{4J7z#1q&RCaO+Uz!H)tC~yionhSUgpig7?!b>Lio2K zA^sr(&J7#mO*Qz&wL<0?a$ULv>jtSf0G5f0rFtN^6n0WdSDy@V?z{U^i}EaFno>OI zw}HlZt`h|%C6txprU;qG!$jO|`FU=MX#L5+r1V0BGB!fz9o7Jx zte!EDX;$znDHU%XQgi6?6;^PL)GLyKLOLk39)la$vP3*MoWxs>$JtW1Y zPJSK_=Ya|4jM3|0>DeF|ok7(xT7bY}(*y?3pQ| z)r{oR$&(<)aaf=wBs8Lv!40D2ZI1H|15ik+=m$e^GG!Ctr6rHV@n51~D30_g)0DnN zc|v)H-_YMj(}Q25V@mqNiUeattXj;P0)`NxCCB$iQBL~?;IZhTM_=)=>t#2$OPblc zq#RSm@~*kZ9HVGdoLESW#c;Bj>4d^t!4P=2Nri*p#l9!@(uaFfS55Mx_`8hqI6MN^ zMMI1?GKohfVNOUNodskFek*JRkAq=LVy%%VkEc|(fY29->?5ZN zcuLsamw>AgPDV(~T!U18;Ul@`!kYS83_um$Q+x!IiUjE!y)C>KpAl?Uc$LW z`jSXh(THtm2LFgMsluqhilb+gppk6oxOm8w5a-wMP0D8_vTpEn2V+JhcMsoP7@{qO zRERHP*+)4cxjH_RNfaal2C&awf1=)2q<$AeDfpqxFhm01Y0R%7Rt}!2ZHF7eKJ+~d zhncei6H5xRu<1JVJLQKV#pHkvdqbDAmr8^v;uARxAq#V0wN#WiU_KO2Xyw@GiaoUm z7M58GrjDr}xv;P~(7lI4>S+Ti0ArcYPxkm@$7mC8L%FF)Ji!qJ+Jxl<|2m4=&UhL7 zJstm+0kVwF!H}CGA*}sa^>_j$k@%p>z|H2?Ol~wseV# z9(JwQZ}Las2N2`n_k>x@q{y5$)%(~E3Nl4UT+NQq==lh@c(C3Qb|>p22Gd+DdgMS+ zDe-TGHu8);t+-$UiV)k0j&4Oez!L$BM6}U812XQuB-dV^0d+`5r#zu%_^iQZ=!C*2 z-gU4yC{1#?z^n4{lEM*UJP(no51&|MRifshHJ~K&QQD1{Yqw6Q4}mBE`%*mcl}beg zf0q{pxj(ry>%)Uf09~?TfLIADX;huj6iL?!Clqfxh~>^vQ%GpkU6Y!K#V<1d3PlPg zlbuowZJMyGC3M6G^!~m^(vp4j!Lmd>16IKOi253UvW5L2i6fv2dft4P#?(>cq z({hA#zitOnprko3>Gu@^D2SfH{LFiUgDct`pN z{K}66Phg5YR%35`ipk2^X6!|rr`T8iB>N#laEZioE9o)HeuKaezc^_mZcr{V2vrl2 z@f!86`uaFs|d8*5hA$35F1Jq0u5J1FCH$coo}IzlSusVT_hx8gVJd)CdyzssHT!&Cw8K& z7Ur<&(IjGSFbvc(uI6{Ap`8kF$2@T3uf@~R@TTaX_j?Al-yiu!P*K=0y81*U2ct73 z($ASeE71n=7HV4E*+9dJOi56G0Bd8ov>&?GXIGAwmgY7)RUvb;l-|AwQb7xYD8ZbF zohgmNd^;kTOoCOs+on6oiaz_>SwpwiOB z-#W$s(-%|DzlT?Ac;m6Ow@73^+j-8>K?YyC%y-e zn3>e_Ia?$yGMUQ7J@mBOl2svSFg?&F)Hq3U$`^ipR1z0$WS{27`0bcpJz;ld=*@XD7Z{ag$*FU<@9(h~M*PehEQpYjt%H zV+quH`@PGkPJqiO$SHZMvcrO4r$k?}=$+k7;*PKizAX6^lU!CFS>{lRHw4<}FQ<)y%Dw9?APN;$a)zA)y* z!Wm-<&!b9rZkGBI=_<3^C4>(uX}=W)!t;W0YRq^lBwOyxGn!Acx}sV_!o{vaUz=g7 z-Sd6oL|r*MY1DJ0rH!*K^ib1-P^;O>lwoS~vkO+8 zX|yt4f1EaNRW_YvT^PJ*Wwb?i+lp8AIT-Tt)cZxy*|^xb+lm=iW>we=>a4^~Rb5Lf z3{8zq-+06$va|(?TrgKdnd=x-;gQ3iR{h>j1)HSb9-*#n<#wWW`EwxJ1Qy?`-s;aU zahqr&y^&YHF1_0wr$pA>E=JD2RX(_bRcj_I;Gvri-*(-)qOa~4u{-R;^V^ud%JX;oF%*Trqt=M0 zfPwV$p|gyWesN;MmCifG^g;7YbZaEBy?!^6vEvlm$Hg1Yqof0yKLY0>Bhtue-H&=v z^~GE@`>$9Z?^kkq0nq~eNJOJ$ zKm!_t+=!W`$)=f@shLT0q1Jj>0$>7edd7PKdlGwYgnYlLZ#DE(gC0UKB7VhaA*tcN z3hMz27zUdH*N5-G@esUn+}aGd43zGz_~uum=-}XBGK~<6pnx!m$Oy}bl#S0v(L&-O zd=M-d|XzTmh?dBn{j9BWaXsqMBPf=O77`&let&Emy|RmB_Q}zzNeeyPJXH2$NluS z2R0&DXi{>gfRmt-$x31BH+qxIL4&8-RJfMuWH6dUQ(b(f_(aRW(P(`VuSVtSbP_n9 zq@pO#FL<9Z->yO=>&xP5aMIh*&_HNOHY-siulP&OT6#6z&2)vpGOoBYxk>Q+=iT_7 z-?7*8z+L3s^WFWi?ySA6KlxkH9nu_<>7EJvDD`A|wsKZ2qp|alJPwi>Urw#yu2R?< zq9{-F33GeDG{NMBgLoJ(FW>TZ7NUWPnHi>u1Z&(>#RMPSZRB`6Th649;O%O~r1s}i zREKF+Iod{inp!bjw=w=q%FFBR@Q{8Md6s$xSJ!MVnDD0mz(sJ&6UwV_thIhU9;?fH zaRgKup5ife!JW6XDM91SnzfWI@#f{)3~Kdk)w#G^ zOKCkk+(>jD!$FFm@E7^(< zuML`h)rtD*ot*b=C5yV9L7icb*~>5U8(a^5Rgb*_zAthob4!P#0*ZG}4fcy&#?RUF zkF#BIcW*5Q`rXFQ3lHrLn+0$0C?}}6c;#?y7b#ebXhX(md9^*NnC?&UY+!?7nX0?u*V?%&^z;{KI~VZ=H5eROSEk zjQ2b)D_|1!(CW~YYcp#*`%-{FIwCqM6UUSK#lwZF7;I5<|@Y5acpj9}g0W&g;wKoFblo7{c+&tac0Zc9r^LmMm)^^PYk z#g30LFKrbqXLohOLsT(2?0$1Vel#A%bhhnsm`i#3^cJ6;b2KEmI?61bP&$9%b-j8o{^roGK&jVlRW@!&J*1kGk1;bE%b?bW%`O_Bz zXQ0b&GP5E+mAP~~(1u2&zh>#UzvG=&NdKdGuZdz)Q=xiI!_(n7xk!_VUrAlV)pLPr z!ML2M^8E`Bt(W6nziC0LUdLI%enF~1-Ro|~42Q0jKqbSk&hm%bB+49@b!mg@^sb#$ z48cDWzuK)$pGPU^h)OTNcIW%Ki*ANCA~12rTC6R#JnrozG4VbL&CM78{0TM@m2qi5 z5+=vrY;{y_Q0?V^&+@Ce>fLN&jpMOuLQl8*q1Cm2F{}NeUzIZZrd>5jv69Di(eh1^ z_od-ck;wZQ!5n;2%WJ5L4JxyBd;HB@p6B#WJ#S{`&RKVr=AuEz`=lgR!UOSr=;4?SH;n&BXdzc+0t(w^{{lzEp{@jZE_G6x#IR>up27bTZ z9wIm2J$mcl9&DPp47?3bLhiA;+-8oV>^i?Z?x-?uxQ{f*x_!lMbD1kL&~F0PnKz~D zR<(EZ@Bd=l^cH`@cr@U?8ilKVeJ{`WrN7Q&cdDoP*!8^jtGlcCIU}u#!1+9D@xJw< z2>*1NpF5RU+);6fwww2|6Xo2hft+UasqgB+YEW}^+uJTL=Eim3;Wh#&w?AiV-XDQ420mL$P;UHMH(S2`uph^%Vb6jM_uGs} z_I`!^WO#&6*E6bw{6MW;;~asm*K6N)%uBDAh$qF4x)NwDslP>g~RZ{~?=Tig#-BLu4-m%7EVYIw4J>`wlp^ zYw&(cr>gJyu&}G|d)>%g-Ff}oxA@ql{5B+M|EKfmN%z+#&)tLeWnoAC@p`6vbI0OK zr>#HULv#DXiZ_v;|LeZicR_2!}f%x;u!7kl@btHV(5 zW0%g;LS8kO@7(TB-EP-z-;;LFO<*|%(rDc`emfCvq!os4qyCd>rsS6c}2K+I#Y?q59 z`)R6Jhc4OkYP$SgWlr+9ch8n7@?+MgKj{v}coQu3ncMSN9^AG;J-Oj%q3U@Ii?7a> z1nDP__ufKjyPH;6E!7#KZ5$QSj>l3tBz22LhpkVCD|tKYUfylHk=h)-ipt9NkERO^ zR%C>7)KbuPtn*t}a zRy>amEhCVARVLK?;}`Ad0yFj#S7Slbo9OC8zm$`nzd#6Evv-Ll(#hBBY}2A}zuOS! zb=Kmtzk6yFIQW8*`XK0Pt)+0Xlc_IA_YL7CB(8+&jO#-!&A{1lVUEp=`dEg^lzE_9 z3#VjUnKp&Tw6jjTRjXC4RpKej>8De(e?@ z14>9r(akE@HFTiwH}fs!($)HaZb*F?ALJ#haYVPVqYM^eV~3&N@NE5~T0b2Xh9Gb> z&A%o&3f}E)j}NovjI1R+@u8avX&9y^aBy1Vs}(Ww6$4*);G&2a{qj8guLE{2WoBh= zWFS+bX@4l!l@=Bkwwm~k93)!HTu?u$j$9-j%5Km;HSDz~ic)N*LCUDg&dJQlwx_z$ zo$H?@OUN9iR59wQwl%pJA0N!Z4Z_vzXtc?(9e&Vs9({l){Udz&)VTa3d=b>2IPif3 z0RHZnpJi$muC_*YhL$$YOiE6sZkDF*j8+cjA4?xw0Av{nX$b%b2mm1UxdA@50dnFV zmSzBeygY#R(-j&35@rbi|Fk}v0B}Ed001l(1OWD#gZwSa1^rL0QZCqk+kYE=oCCfn zS=hVSJ6qU05VJ8d1HOnz%Y*;z?Gyjl6#tmW^90e$aezATQsB z#P_ov0FDBIO2Q%xiKc7_Me2yo8jz3&O(s&?i=i@eMb2jA6bJ*0iG_`WOF>CRO+(Ah z!O8W7n@3bkTtZSxT1Hh(T|-k#TgTYM)Xdz%(#qMz)y>_*(<>-ABs45MA~G>4IVCkM z{YOTAL19sGNoiSmU427iQ*%peTVMac;Lz~zkZ&;{{xu6fcpj?%1@tNSDA))_M_rEqi)<44% z;$sB>4+ioXOkgMgLBRVvb$%p(7QLl8(Y!fkp)d|_9zSJ$j;zUBbEvyfFs_T{D4Y5! zr#}wtgvA0=pEl9kv(bQQBAbQ`5I&8HAsZAT=*xJQI3!0W>Tq#(@U8t@fbswyFqgk0KCaRX>a z=2BVhne3KfY?nM-0GT{Mt~#@utD@n5BJgio-tmq)(T#OraF$&U?;=)S4-ewnPK5q2 z2Fy0_@&Y?rF8kkWjv`PC^Fa5- z<3eZlRxbF-OdX-2EoK;SJNup2e${wD1NW^f=qj!crSUPwK&g3w9+i~EqG|8I@+VL! zum|zY8~(+}o+a)J!hlbY6Wd0I`L<*~fpK3(X!Wi?;l}VUj{^P75qFPBbxewF(r7{v zYOrX;{#=ZN>%-m2lq-AL(3Q`B>Xn;853+JwfG@04Ucpe;#yuB8YQ{9u613;pPw>pE z12sK)C=#HhJzz^}DZus}!6*alS5qf@j!V=HT}bX5_9ui28Ghz;dZ=F}^VvAS{_C7x zE?M_HVC2a?`rfJ)qn(lC+gkH@>j%Ij=u+F;LVr=<$CaD)S!Z?Klb*rF8<(J57pV{3 z!hJPL?={=@WHo2dPCK^16hdFtv^=!YyWC7>sL1f#T2Md)yTPj6u7+xMPDURkgAyMiPn=+@TJC=uOC%tP_|Du3xT zP9_{EP>skO|D@!;Vns{ZZrcho9$xbX?X8Xx zX>ASh{oyk)x9pk1wtAD!mHe1_KN8@4rJVEQ^5O0Ry8hBvG(^~rc|Bs5vPkFISA=i> z{(E;RXu`*^6d1G{cJ@|&tOGST=52s{q?2;SW1C%XB!)&`cNIks1@;B}wF4k<&8KA4<$_AK4H`6OeQVpd7tD(we2RXq2c3xW#xD&Dh`*-BM zu2Nt4_fnC;W(*s7Avfg*Fa-{}&GQo|Bg~@rzk(vwRu9ER6Jobs84NL@9Hq&q+g)rb zH&Ye#ySV#wjV`NR(9tgLxe4S1Wl?0zK6JU=H|1RMO+rReSAjjE%?dyOV-Nd?@L%~$ zb!ye-_jz3VVq=r8TAu~xfSPBN1%|fe$G6AsQEhnXD^!H#yWoBj-Nb&N9!94_2KX*? zvZf4(NhI@jUtPqbF8u5p{5W1P^zQ6`SNUNLZj8NXG}qm9SEhUb2wpE7Hft*P68$DK z?2?!X&C=Yx%|4|cG;GX*NgzPYC61>u>+KIfG*P_^*7Ic_g9L(cf51Uk+l;Fm8Ks{k zF3uwM7XrM1O~>k%E@U5xu$|3*TdEy~&g2Xys|5DI4HcXuYgSi$WVd|zq2nvkYXf*XEann`X zB0k9mldKEJtV6!oJ$S#u#bF|p&u3wz!}yx#akvZpTKzKQ{65`SUSm^HzV7P?qDb3F ziw%VW(x@lSg#}ps`^?vJ0q-g{qCmXz6{ovx*2ln*B%46t!aZ}XiP<=lD9!ke zLN#_P7C|xO1AyKkzC+;m0oZOHu*H=}8^q<4WtbNVYfk0-f-1I^jaS9}K$Qs=ovD+o zmm&D&Rr-o;*FD&da8>E*ZY7eYPqFy@4d3gWi01>)lUjH+)ngFz&ekGp%?~S2N%_S) zOZJgAXwjT;GjQ=tUU{BFo=dvX~+53O!N5#q=*jyN{6=TP8Qj= zL7%R-^(UK?3zKEnmR?({@2RP_!N`cr{GLM!AP+yUJt>0w1iq2hK@1EEo=fu8Y*2e*oMa$cY?-gott;z1R&J zHis5~zNWscK-IoKn^yCOwdo}}?oQC56ba6cnhXg?{Z(`;`EMbD<|1`XWyR|!XwrBR zlx>|q*16zK9eSO3qJx4AgnYPxs#lNOj6WO;UU}!p<`}Aqxlr@j1dgG>xSfUph>#Av zuy?e8*QWaGoPoH{OHxbQGLK-_6CHG)`3CgbnPIiJ + + + + + + + + diff --git a/tests/demos/webserial/index.html b/tests/demos/webserial/index.html new file mode 100644 index 0000000..0d7c8b3 --- /dev/null +++ b/tests/demos/webserial/index.html @@ -0,0 +1,94 @@ + + + + avrgirl test + + + + +
+
+
+

Upload-o-matic

+

Choose a program to upload to an arduino

+ +
+ + + + + +
+
+
+ +
+
+
+
+
+
+ + + + diff --git a/tests/demos/webserial/js/avrgirl-arduino.global.js b/tests/demos/webserial/js/avrgirl-arduino.global.js new file mode 120000 index 0000000..1629f82 --- /dev/null +++ b/tests/demos/webserial/js/avrgirl-arduino.global.js @@ -0,0 +1 @@ +../../../../dist/avrgirl-arduino.global.js \ No newline at end of file diff --git a/tests/demos/webserial/style.css b/tests/demos/webserial/style.css new file mode 100644 index 0000000..9ba03ea --- /dev/null +++ b/tests/demos/webserial/style.css @@ -0,0 +1,218 @@ +body { + font-family: sans-serif; + background-color: #3F2B96; + background-color: #503bad; + padding: 0px; + margin: 0px; +} + +.main { + height: 100%; + text-align: center; + min-height: 24em; + overflow: hidden; +} + +.wrapper { + text-align: left; + overflow: hidden; + width: 1000px; + margin: 100px auto; +} + +.wrapper div { + float: left; + width: 400px; +} + +.bot { + float: left; + position: relative; + z-index: 999; + border-radius: 20px; + border: 2px solid #aaa; + background-color: #fafafa; + background-color: #eee; + box-shadow: 3px 3px 3px rgba(0,0,0,0.2); + padding: 20px; + margin-right: 100px; + height: 300px; + width: 400px; +} + +.bot h1 { + padding-top: 0; + margin-top: 0; + font-family: 'Fugaz One', cursive; + color: #333; +} + +.board { + width: 400px; + position: relative; + z-index: 999; +} + +.board img { + height: 330px; +} + +.board svg { + font-family: sans-serif; +} + +label, input, select { + display: block; + margin: 0 0 15px 0; + width: 200px; +} + +select, input { + height: 30px; + margin-top: 8px; + font-size: 15px; +} + +.fileButtonWrapper { + display: block; +} + +#fileButton, button[type=submit] { + background-color: #acd3f6; + border: 1px solid #7998b4; + border-radius: 4px; + padding: 4px 8px 4px 8px; + position: relative; + overflow: hidden; + margin-right: 20px; + margin-top: 8px; + cursor: pointer; + font-size: 16px; +} + +input[type=file] { + position: absolute; + top: 0; + right: 0; + filter: alpha(opacity=0); + opacity: 0; + outline: none; + background: white; + cursor: inherit; + display: block; +} + +input[type=file]:focus { + outline: 3px solid #0000ff; + border: 3px solid #0000ff; +} + +button[type=submit] { + float: right; + font-size: 20px; + margin-top: 20px; + margin-right: 5px; + background-color: #99f89c; + border: 2px solid #7fc381; + padding: 10px; + border-radius: 7px; +} + +#fileName { + min-width: 175px; + max-width: 175px; + max-height: 20px; + color: #666; + overflow: hidden; + position: relative; + text-overflow: ellipsis; +} + +#gear { + position: absolute; + margin-top: 60px; + z-index: 1000; + margin-left: 400px; + width: 80px; + height: 80px; +} + +@keyframes rotation { + from { + transform: rotate(0deg); + } + to { + transform: rotate(359deg); + } +} + +.spinning { + animation: rotation 0.8s infinite linear; +} + +#progress, #pipe { + position: absolute; + margin-top: 85px; + margin-left: 461px; + z-index: 1; + text-align: left; + width: 100px; + max-width: 100px; + height: 20px; + overflow: hidden; + border: 2px solid #f6f6f6; + border: 2px solid #aaa; + background-color: #fff; + background-color: #eee; + box-shadow: 3px 3px 3px rgba(0,0,0,0.2); +} + +#progress { + width: 0px; + background-color: #99f89c; + z-index: 3; + color: forestgreen; + text-align: center; + text-transform: uppercase; + padding-top: 2px; + height: 17px; + font-size: 15px; + font-weight: bold; + transition: width 0.2s; +} + +#logbox { + position: relative; + text-align: left; + width: 922px; + max-width: 922px; + margin-top: 30px; + margin-left: 30px; +} + +#logbox h2 { + color: #ad9aff; +} + +#log { + position: relative; + text-align: left; + width: 922px; + max-width: 922px; + margin-top: 10px; +} + +#log > span { + margin-left: 5px; + margin-bottom: 5px; + border: 1px solid #0000ff; + color: blue; + border-radius: 4px; + background-color: #ad9aff; + padding: 1px 4px; + font-family: monospace; + font-size: 9px; + float: left; + display: inline-block; +} + diff --git a/webpack.config.js b/webpack.config.js index 1ed6ebb..e1516b9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,6 +8,9 @@ const importableConfig = { filename: 'avrgirl-arduino.js', libraryTarget: 'umd' }, + optimization: { + minimize: false, + } }; const importableMinConfig = { From aec77ea02033dfa0d848896f336da809db8748e4 Mon Sep 17 00:00:00 2001 From: Suz Hinton Date: Sat, 28 Dec 2019 19:39:34 -0800 Subject: [PATCH 34/94] actually close connection to avr109 boards due to fixed node-serialport/issues/415 --- lib/avr109.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/avr109.js b/lib/avr109.js index 0f13fb6..a56393a 100644 --- a/lib/avr109.js +++ b/lib/avr109.js @@ -50,8 +50,7 @@ Avr109.prototype._upload = function(file, callback) { var color = (error ? colors.red : colors.green); _this.debug(color('flash complete.')); - // Can't close the serialport on avr109 boards >> node-serialport/issues/415 - // _this.serialPort.close(); + _this.connection.serialPort.close(); return callback(error); }); From 76020202ea40008a339cb9af837d03f234b35bbb Mon Sep 17 00:00:00 2001 From: Suz Hinton Date: Sun, 29 Dec 2019 10:53:53 -0800 Subject: [PATCH 35/94] document alpha web serial support --- README.md | 2 ++ tests/demos/webserial/README.md | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/demos/webserial/README.md diff --git a/README.md b/README.md index 2fee086..1a98778 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ A NodeJS library for flashing compiled sketch files to Arduino microcontroller boards. +🆕[Alpha release of web serial support](tests/demos/webserial) for some Arduino boards 🆕 + **Want to [contribute](CONTRIBUTING.md)?** **Own a supported Arduino and want to be a test pilot for this project with two minutes of your time?** diff --git a/tests/demos/webserial/README.md b/tests/demos/webserial/README.md new file mode 100644 index 0000000..d0c883d --- /dev/null +++ b/tests/demos/webserial/README.md @@ -0,0 +1,36 @@ +# Web Serial Demo of AvrGirl Arduino + +⚠️ Web serial support in AvrGirl Arduino is alpha right now and not guaranteed to be stable and full featured. ⚠️ + +This directory contains a simple web app example of how to use Avrgirl Arduino in the browser. + + +## How to navigate this example + +Most of the functionality is contained within `index.html`. All of the HTML elements are optional - they provide an interactive way to choose a file to upload and the Arduino board type. If you can provide a hex file in text format, you can avoid using an UI to source a file. + +This example uses the 'global' type of AvrGirl Arduino library distribution, which means that the `AvrgirlArduino` instance is available on the browser's `window` object. + +You can also use this library as an ES module and bundle it along with your app's code using a tool such a [webpack](https://webpack.js.org/). + +## How to run this example + +The fastest way to run this example is to git clone this repository, and run a local web server from this directory. If you have Python installed, [Simple HTTP Server](https://docs.python.org/3.8/library/http.server.html?highlight=http%20server#module-http.server) is a great tool for this, or you can also install [http-server](https://www.npmjs.com/package/http-server) from npm. + +1. Install NodeJS or Python 3 +2. In your terminal, run `git clone https://github.com/noopkat/avrgirl-arduino` +3. Run `cd avrgirl-arduino/tests/demos/webserial` + +For Python 3, run `python -m http.server 3000` + +For NodeJS, run `npx http-server -p 3000` + +You can then navigate to `http://localhost:3000` in Chrome and play with the app from there. + +## Caveats + +Currently there is no support for AVR109 / boards that use USB emulation on chip. This includes boards such as Arduino Leonardo, Arduino Micro, Arduboy, etc. There are some technical limitations behind this, and be my guest to give this a try if you're up for a challenge because it's definitely possible to hack this in, it's just something not included with this alpha release. + +## Find bugs / problems? + +I'd love for you to open an issue or a pull request! This is super new and not thoroughly tested so you'll be helping us move towards beta and full releases by contributing. Thank you! From 1ba031284a23352c92c4be458bc2f3d73f58a877 Mon Sep 17 00:00:00 2001 From: Suz Hinton Date: Sun, 29 Dec 2019 11:13:11 -0800 Subject: [PATCH 36/94] linting --- .eslintrc.json | 9 ++++++--- lib/browser-serialport.js | 19 ++++++++++--------- lib/connection-browser.js | 6 +++--- tests/avrgirl-arduino.spec.js | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 157bb1b..ba0d5e7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,10 +1,11 @@ { "env": { "node": true, - "es6": true + "es2020": true, + "browser": true }, "parserOptions": { - "ecmaVersion": 6, + "ecmaVersion": 2020, "sourceType": "module", "ecmaFeatures": { "jsx": true @@ -47,6 +48,8 @@ "no-eq-null": 0, // Warn when there are dangling commas - "comma-dangle": ["warn", "never"] + "comma-dangle": ["warn", "never"], + + "no-irregular-whitespace": ["warn"] } } diff --git a/lib/browser-serialport.js b/lib/browser-serialport.js index d4f37ff..5203597 100644 --- a/lib/browser-serialport.js +++ b/lib/browser-serialport.js @@ -16,7 +16,7 @@ class SerialPort extends EventEmitter { this.requestOptions = this.options.requestOptions || {}; if (this.options.autoOpen) this.open(); - } + } list(callback) { return navigator.serial.getPorts() @@ -25,7 +25,7 @@ class SerialPort extends EventEmitter { } open(callback) { - navigator.serial.requestPort(this.requestOptions) + window.navigator.serial.requestPort(this.requestOptions) .then(serialPort => { this.port = serialPort; if (this.isOpen) return; @@ -37,19 +37,19 @@ class SerialPort extends EventEmitter { this.emit('open'); this.isOpen = true; callback(null); - try { - while (this.port.readable.locked) { + while (this.port.readable.locked) { + try { const { value, done } = await this.reader.read(); if (done) { break; } this.emit('data', Buffer.from(value)); + } catch (e) { + console.error(e); } - } catch (e) { - throw e; } - }) - .catch(error => {callback(error)}); + }) + .catch(error => {callback(error)}); } async close(callback) { @@ -81,8 +81,9 @@ class SerialPort extends EventEmitter { } async read(callback) { + let buffer; try { - const buffer = await this.reader.read(); + buffer = await this.reader.read(); } catch (error) { if (callback) return callback(error); throw error; diff --git a/lib/connection-browser.js b/lib/connection-browser.js index d7061bd..f44c2fb 100644 --- a/lib/connection-browser.js +++ b/lib/connection-browser.js @@ -11,9 +11,9 @@ var Connection = function(options) { }; Connection.prototype._init = function(callback) { - this._setUpSerial(function(error) { + this._setUpSerial(function(error) { return callback(error); - }); + }); }; /** @@ -26,7 +26,7 @@ Connection.prototype._setUpSerial = function(callback) { autoOpen: false }); this.serialPort.on('open', function() { -// _this.emit('connection:open'); + // _this.emit('connection:open'); }) return callback(null); }; diff --git a/tests/avrgirl-arduino.spec.js b/tests/avrgirl-arduino.spec.js index 3634b2d..aa9154a 100644 --- a/tests/avrgirl-arduino.spec.js +++ b/tests/avrgirl-arduino.spec.js @@ -23,7 +23,7 @@ var Connection = proxyquire.noCallThru().load('../lib/connection', }); // module to test -var Avrgirl = proxyquire('../avrgirl-arduino', { Connection: Connection }); +var Avrgirl = proxyquire('../', { Connection: Connection }); // default options var DEF_OPTS2 = { From d48058db01c2abf73b819c956e77d849d88db4c2 Mon Sep 17 00:00:00 2001 From: Suz Hinton Date: Sun, 29 Dec 2019 11:14:53 -0800 Subject: [PATCH 37/94] 4.2.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3eca040..de9df65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "avrgirl-arduino", - "version": "4.1.0", + "version": "4.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9bbec51..47bc346 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "avrgirl-arduino", - "version": "4.1.0", + "version": "4.2.0", "description": "A NodeJS library for flashing compiled sketch files to Arduino microcontroller boards.", "bin": "./bin/cli.js", "main": "avrgirl-arduino-node.js", From 36a495f2873fa9956438d918e74da2ec6afbebff Mon Sep 17 00:00:00 2001 From: slightlycyborg Date: Sun, 5 Jan 2020 20:12:57 +0000 Subject: [PATCH 38/94] webserial demo: script is utf-8 --- tests/demos/webserial/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/demos/webserial/index.html b/tests/demos/webserial/index.html index 0d7c8b3..fa890cc 100644 --- a/tests/demos/webserial/index.html +++ b/tests/demos/webserial/index.html @@ -39,7 +39,7 @@

Upload-o-matic

- +