"use strict";(function(){"use strict";global.Promise=require("bluebird");var e=require("co");function r(e,r,o){var n=false;var t=function c(e){if(!n){n=true;o(e)}};e.once("error",t);e.once("connected",function(){e.removeListener("error",t);if(!n){n=true;o(null,e)}});e.connect(r);1}function o(e,r,o,n){var t=false;var c=function u(e){if(!t){t=true;n(e)}};var s=function a(){if(!t){t=true;n(new Error("close"))}};var i=e.exec(r,function(r){if(!t){t=true;e.removeListener("error",c);e.removeListener("close",s);n(null,r)}},o);if(!i){if(!t){t=true;e.removeListener("error",c);e.removeListener("close",s);n(new Error("exec error"))}}else{e.once("error",c);e.once("close",s)}}exports.connectPro=function(e,o){return Promise.promisify(r)(e,o)};exports.execPro=function(e,r,n){return Promise.promisify(o)(e,r,n)};exports.test=function(){var e=require("./deviceLink");var n=new e;r(n,{protocal:"telnet",host:"192.168.23.191",port:23,username:"adm",password:"adm",enablePassword:"adm",encoding:"utf-8"},function(e,r){console.log("in _connect, err:",e);if(!e){o(n,"show version",undefined,function(e,r){console.log("in _exec: err",e);if(!e){console.log("resp:",r)}})}})};exports.testPro=function(){var e=require("./deviceLink");var r=new e;exports.connectPro(r,{protocal:"telnet",host:"192.168.23.191",port:23,username:"adm",password:"adm",enablePassword:"adm",encoding:"utf-8"}).then(function(e){return exports.execPro(r,"show version",undefined)}).then(function(e){console.log("exec success, resp:",e)}).catch(function(e){console.log("error occur, err:",e)}).finally(function(){r.disConnect()})};exports.testCo=function(){var r=require("./deviceLink");var o=new r;e(regeneratorRuntime.mark(function n(){var e;return regeneratorRuntime.wrap(function r(n){while(1){switch(n.prev=n.next){case 0:n.prev=0;n.next=3;return exports.connectPro(o,{protocal:"telnet",host:"192.168.23.191",port:23,username:"adm",password:"adm",enablePassword:"adm",encoding:"utf-8"});case 3:n.next=5;return exports.execPro(o,"show version");case 5:e=n.sent;console.log("resp:",e);n.next=9;return exports.execPro(o,"show memory");case 9:e=n.sent;console.log("resp",e);n.next=16;break;case 13:n.prev=13;n.t0=n["catch"](0);console.log("error occur:",n.t0);case 16:case"end":return n.stop()}}},n,this,[[0,13]])})).catch(function(e){console.log("outer error occur:",e)}).finally(function(){o.disConnect()})}})();