New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babble

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babble - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

examples/ask_age.js

4

dist/babble.min.js

@@ -1,3 +0,3 @@

!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.babble=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var s=e[a]={exports:{}};t[a][0].call(s.exports,function(n){var e=t[a][1][n];return i(e?e:n)},s,s.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,n){n.exports=t("./lib/babble")},{"./lib/babble":3}],2:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(!t)throw new Error("id required");this.id=t,this.listeners={},this.conversations={}}var r=t("node-uuid"),i=t("./pubsub"),o=(t("./block/Block"),t("./block/Action"),t("./block/Tell")),a=t("./block/Listen");e.prototype.subscribe=function(t,n){if("function"==typeof t&&(n=t,t=null),t||(t=i["default"]()),"function"!=typeof t.subscribe)throw new Error("pubsub must contain a function subscribe(params: {id: string, callback: function}) : function");if("function"!=typeof t.publish)throw new Error("pubsub must contain a function publish(params: {id: string, message: *})");var e=this,r=t.subscribe({id:this.id,message:function(t){var n,r,i=JSON.parse(t.message);n=e.conversations[t.id],n?e._run(n,i):(r=e.listeners[i],r&&(n={id:t.id,peer:t.from,next:r,context:{from:t.from}},e._run(n,i)))},connect:n});if("function"!=typeof r)throw new Error("pubsub.subscribe must return a function to unsubscribe");return this.unsubscribe=r,this.publish=t.publish,this},e.prototype.unsubscribe=function(){throw new Error("Cannot unsubscribe: not subscribed")},e.prototype.publish=function(){throw new Error("Cannot publish: not subscribed")},e.prototype.listen=function u(t,n){if("string"!=typeof t)throw new TypeError("Parameter message must be a string");var u=new a(n);return this.listeners[t]=u,u},e.prototype.tell=function(t,n){var e=r.v4(),i=new o,u={id:e,peer:t,next:i,context:{from:t}},f=this;return i.then=function s(t){return u.next=t,t instanceof a?f.conversations[e]=u:(n=f._run(u,n),t.then=s),t},n=this._run(u,n),i},e.prototype.ask=function(t,n,e){return this.tell(t,n).listen(e)},e.prototype._run=function(t,n){delete this.conversations[t.id];var e=t.next;do{var r=e.execute(n,t.context);n=r.result,e instanceof o&&this.publish(t.peer,{id:t.id,from:this.id,to:t.peer,message:JSON.stringify(n)}),e=r.block,e instanceof a&&(t.next=e,this.conversations[t.id]=t)}while(e&&!(e instanceof a));return n},n.exports=e},{"./block/Action":4,"./block/Block":5,"./block/Listen":7,"./block/Tell":8,"./pubsub":9,"node-uuid":20}],3:[function(t,n,e){var r=t("./Babbler"),i=t("./block/Tell"),o=t("./block/Action"),a=t("./block/Decision");e.babbler=function(t){return new r(t)},e.tell=function(t){var n="function"==typeof t?t:function(){return t};return new i(n)},e.decide=function(t,n){return new a(t,n)},e.run=function(t){return new o(t)},e.Babbler=r,e.block={Block:t("./block/Block"),Action:t("./block/Action"),Decision:t("./block/Decision"),Listen:t("./block/Listen"),Tell:t("./block/Tell")},e.pubsub=t("./pubsub")},{"./Babbler":2,"./block/Action":4,"./block/Block":5,"./block/Decision":6,"./block/Listen":7,"./block/Tell":8,"./pubsub":9}],4:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if("function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.run=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],5:[function(t,n){function e(){this.next=null,this.previous=null}e.prototype.execute=function(){throw new Error("Cannot run an abstract Block")},e.prototype.then=function(t){if(!(t instanceof e))throw new TypeError("Parameter next must be a Block");for(var n=this;n.next;)n=n.next;for(var r=this;r.previous;)r=r.previous;return t.previous=this,n.next=t,r},n.exports=e},{}],6:[function(t,n){function e(t,n){var r,i;if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if("function"==typeof t?(r=t,i=n):(r=null,i=t),r){if("function"!=typeof r)throw new TypeError("Parameter decision must be a function")}else r=function(t){return t};if(i&&i instanceof Function)throw new TypeError("Parameter choices must be an object");if(this.decision=r,this.choices={},i){var o=this;Object.keys(i).forEach(function(t){o.addChoice(t,i[t])})}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.decision(t,n);if("string"!=typeof e)throw new TypeError("Decision function must return a string containing the id of the next block");var r=this.choices[e];if(!r)throw new Error('Block with id "'+e+'" not found');return{result:t,block:r}},e.prototype.addChoice=function(t,n){if("string"!=typeof t)throw new TypeError("String expected as choice id");if(!(n instanceof r))throw new TypeError("Block expected as choice");if(t in this.choices)throw new Error('Choice with id "'+t+'" already exists');return this.choices[t]=n,this},r.prototype.decide=function(t,n){var r=new e(t,n);return this.then(r)},n.exports=e},{"./Block":5}],7:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(t&&"function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t||function(t){return t}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.listen=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],8:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(t&&"function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t||function(t){return t}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.tell=function(t){var n="function"==typeof t?t:function(){return t},r=new e(n);return this.then(r)},n.exports=e},{"./Block":5}],9:[function(t,n,e){e["pubsub-js"]=function(){var n=t("pubsub-js");return{subscribe:function(t){var e=n.subscribe(t.id,function(n,e){t.message(e)});return"function"==typeof t.connect&&t.connect(),function(){n.unsubscribe(e)}},publish:function(t,e){n.publish(t,e)}}},e.pubnub=function(n){var e;if("undefined"!=typeof window){if("undefined"==typeof window.PUBNUB)throw new Error("Please load pubnub first in the browser");e=window.PUBNUB}else e=t("pubnub");var r=e.init(n);return{subscribe:function(t){return r.subscribe({channel:t.id,message:t.message,connect:t.connect}),function(){r.unsubscribe(t.id)}},publish:function(t,n){r.publish({channel:t,message:n})}}},e["default"]=e["pubsub-js"]},{pubnub:"NaMlu/","pubsub-js":21}],10:[function(t,n){function e(t,n){if(t.length%a!==0){var e=t.length+(a-t.length%a);t=o.concat([t,u],e)}for(var r=[],i=n?t.readInt32BE:t.readInt32LE,f=0;f<t.length;f+=a)r.push(i.call(t,f));return r}function r(t,n,e){for(var r=new o(n),i=e?r.writeInt32BE:r.writeInt32LE,a=0;a<t.length;a++)i.call(r,t[a],4*a,!0);return r}function i(t,n,i,a){o.isBuffer(t)||(t=new o(t));var u=n(e(t,a),t.length*f);return r(u,i,a)}var o=t("buffer").Buffer,a=4,u=new o(a);u.fill(0);var f=8;n.exports={hash:i}},{buffer:17}],11:[function(t,n,e){function r(t,n,e){u.isBuffer(n)||(n=new u(n)),u.isBuffer(e)||(e=new u(e)),n.length>p?n=t(n):n.length<p&&(n=u.concat([n,d],p));for(var r=new u(p),i=new u(p),o=0;p>o;o++)r[o]=54^n[o],i[o]=92^n[o];var a=t(u.concat([r,e]));return t(u.concat([i,a]))}function i(t,n){t=t||"sha1";var e=h[t],i=[],a=0;return e||o("algorithm:",t,"is not yet supported"),{update:function(t){return u.isBuffer(t)||(t=new u(t)),i.push(t),a+=t.length,this},digest:function(t){var o=u.concat(i),a=n?r(e,n,o):e(o);return i=null,t?a.toString(t):a}}}function o(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function a(t,n){for(var e in t)n(t[e],e)}var u=t("buffer").Buffer,f=t("./sha"),s=t("./sha256"),c=t("./rng"),l=t("./md5"),h={sha1:f,sha256:s,md5:l},p=64,d=new u(p);d.fill(0),e.createHash=function(t){return i(t)},e.createHmac=function(t,n){return i(t,n)},e.randomBytes=function(t,n){if(!n||!n.call)return new u(c(t));try{n.call(this,void 0,new u(c(t)))}catch(e){n(e)}},a(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(t){e[t]=function(){o("sorry,",t,"is not implemented yet")}})},{"./md5":12,"./rng":13,"./sha":14,"./sha256":15,buffer:17}],12:[function(t,n){function e(t,n){t[n>>5]|=128<<n%32,t[(n+64>>>9<<4)+14]=n;for(var e=1732584193,r=-271733879,s=-1732584194,c=271733878,l=0;l<t.length;l+=16){var h=e,p=r,d=s,g=c;e=i(e,r,s,c,t[l+0],7,-680876936),c=i(c,e,r,s,t[l+1],12,-389564586),s=i(s,c,e,r,t[l+2],17,606105819),r=i(r,s,c,e,t[l+3],22,-1044525330),e=i(e,r,s,c,t[l+4],7,-176418897),c=i(c,e,r,s,t[l+5],12,1200080426),s=i(s,c,e,r,t[l+6],17,-1473231341),r=i(r,s,c,e,t[l+7],22,-45705983),e=i(e,r,s,c,t[l+8],7,1770035416),c=i(c,e,r,s,t[l+9],12,-1958414417),s=i(s,c,e,r,t[l+10],17,-42063),r=i(r,s,c,e,t[l+11],22,-1990404162),e=i(e,r,s,c,t[l+12],7,1804603682),c=i(c,e,r,s,t[l+13],12,-40341101),s=i(s,c,e,r,t[l+14],17,-1502002290),r=i(r,s,c,e,t[l+15],22,1236535329),e=o(e,r,s,c,t[l+1],5,-165796510),c=o(c,e,r,s,t[l+6],9,-1069501632),s=o(s,c,e,r,t[l+11],14,643717713),r=o(r,s,c,e,t[l+0],20,-373897302),e=o(e,r,s,c,t[l+5],5,-701558691),c=o(c,e,r,s,t[l+10],9,38016083),s=o(s,c,e,r,t[l+15],14,-660478335),r=o(r,s,c,e,t[l+4],20,-405537848),e=o(e,r,s,c,t[l+9],5,568446438),c=o(c,e,r,s,t[l+14],9,-1019803690),s=o(s,c,e,r,t[l+3],14,-187363961),r=o(r,s,c,e,t[l+8],20,1163531501),e=o(e,r,s,c,t[l+13],5,-1444681467),c=o(c,e,r,s,t[l+2],9,-51403784),s=o(s,c,e,r,t[l+7],14,1735328473),r=o(r,s,c,e,t[l+12],20,-1926607734),e=a(e,r,s,c,t[l+5],4,-378558),c=a(c,e,r,s,t[l+8],11,-2022574463),s=a(s,c,e,r,t[l+11],16,1839030562),r=a(r,s,c,e,t[l+14],23,-35309556),e=a(e,r,s,c,t[l+1],4,-1530992060),c=a(c,e,r,s,t[l+4],11,1272893353),s=a(s,c,e,r,t[l+7],16,-155497632),r=a(r,s,c,e,t[l+10],23,-1094730640),e=a(e,r,s,c,t[l+13],4,681279174),c=a(c,e,r,s,t[l+0],11,-358537222),s=a(s,c,e,r,t[l+3],16,-722521979),r=a(r,s,c,e,t[l+6],23,76029189),e=a(e,r,s,c,t[l+9],4,-640364487),c=a(c,e,r,s,t[l+12],11,-421815835),s=a(s,c,e,r,t[l+15],16,530742520),r=a(r,s,c,e,t[l+2],23,-995338651),e=u(e,r,s,c,t[l+0],6,-198630844),c=u(c,e,r,s,t[l+7],10,1126891415),s=u(s,c,e,r,t[l+14],15,-1416354905),r=u(r,s,c,e,t[l+5],21,-57434055),e=u(e,r,s,c,t[l+12],6,1700485571),c=u(c,e,r,s,t[l+3],10,-1894986606),s=u(s,c,e,r,t[l+10],15,-1051523),r=u(r,s,c,e,t[l+1],21,-2054922799),e=u(e,r,s,c,t[l+8],6,1873313359),c=u(c,e,r,s,t[l+15],10,-30611744),s=u(s,c,e,r,t[l+6],15,-1560198380),r=u(r,s,c,e,t[l+13],21,1309151649),e=u(e,r,s,c,t[l+4],6,-145523070),c=u(c,e,r,s,t[l+11],10,-1120210379),s=u(s,c,e,r,t[l+2],15,718787259),r=u(r,s,c,e,t[l+9],21,-343485551),e=f(e,h),r=f(r,p),s=f(s,d),c=f(c,g)}return Array(e,r,s,c)}function r(t,n,e,r,i,o){return f(s(f(f(n,t),f(r,o)),i),e)}function i(t,n,e,i,o,a,u){return r(n&e|~n&i,t,n,o,a,u)}function o(t,n,e,i,o,a,u){return r(n&i|e&~i,t,n,o,a,u)}function a(t,n,e,i,o,a,u){return r(n^e^i,t,n,o,a,u)}function u(t,n,e,i,o,a,u){return r(e^(n|~i),t,n,o,a,u)}function f(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function s(t,n){return t<<n|t>>>32-n}var c=t("./helpers");n.exports=function(t){return c.hash(t,e,16)}},{"./helpers":10}],13:[function(t,n){!function(){var t,e,r=this;t=function(t){for(var n,n,e=new Array(t),r=0;t>r;r++)0==(3&r)&&(n=4294967296*Math.random()),e[r]=n>>>((3&r)<<3)&255;return e},r.crypto&&crypto.getRandomValues&&(e=function(t){var n=new Uint8Array(t);return crypto.getRandomValues(n),n}),n.exports=e||t}()},{}],14:[function(t,n){function e(t,n){t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var e=Array(80),u=1732584193,f=-271733879,s=-1732584194,c=271733878,l=-1009589776,h=0;h<t.length;h+=16){for(var p=u,d=f,g=s,w=c,b=l,y=0;80>y;y++){e[y]=16>y?t[h+y]:a(e[y-3]^e[y-8]^e[y-14]^e[y-16],1);var v=o(o(a(u,5),r(y,f,s,c)),o(o(l,e[y]),i(y)));l=c,c=s,s=a(f,30),f=u,u=v}u=o(u,p),f=o(f,d),s=o(s,g),c=o(c,w),l=o(l,b)}return Array(u,f,s,c,l)}function r(t,n,e,r){return 20>t?n&e|~n&r:40>t?n^e^r:60>t?n&e|n&r|e&r:n^e^r}function i(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function o(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function a(t,n){return t<<n|t>>>32-n}var u=t("./helpers");n.exports=function(t){return u.hash(t,e,20,!0)}},{"./helpers":10}],15:[function(t,n){var e=t("./helpers"),r=function(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e},i=function(t,n){return t>>>n|t<<32-n},o=function(t,n){return t>>>n},a=function(t,n,e){return t&n^~t&e},u=function(t,n,e){return t&n^t&e^n&e},f=function(t){return i(t,2)^i(t,13)^i(t,22)},s=function(t){return i(t,6)^i(t,11)^i(t,25)},c=function(t){return i(t,7)^i(t,18)^o(t,3)},l=function(t){return i(t,17)^i(t,19)^o(t,10)},h=function(t,n){var e,i,o,h,p,d,g,w,b,y,v,m,E=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),I=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),B=new Array(64);t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var b=0;b<t.length;b+=16){e=I[0],i=I[1],o=I[2],h=I[3],p=I[4],d=I[5],g=I[6],w=I[7];for(var y=0;64>y;y++)B[y]=16>y?t[y+b]:r(r(r(l(B[y-2]),B[y-7]),c(B[y-15])),B[y-16]),v=r(r(r(r(w,s(p)),a(p,d,g)),E[y]),B[y]),m=r(f(e),u(e,i,o)),w=g,g=d,d=p,p=r(h,v),h=o,o=i,i=e,e=r(v,m);I[0]=r(e,I[0]),I[1]=r(i,I[1]),I[2]=r(o,I[2]),I[3]=r(h,I[3]),I[4]=r(p,I[4]),I[5]=r(d,I[5]),I[6]=r(g,I[6]),I[7]=r(w,I[7])}return I};n.exports=function(t){return e.hash(t,h,32,!0)}},{"./helpers":10}],16:[function(t,n){t=function e(n,r,i){function o(u,f){if(!r[u]){if(!n[u]){var s="function"==typeof t&&t;if(!f&&s)return s(u,!0);if(a)return a(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=r[u]={exports:{}};n[u][0].call(c.exports,function(t){var e=n[u][1][t];return o(e?e:t)},c,c.exports,e,n,r,i)}return r[u].exports}for(var a="function"==typeof t&&t,u=0;u<i.length;u++)o(i[u]);return o}({PcZj9L:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;if("base64"===n&&"string"===i)for(t=x(t);t.length%4!==0;)t+="=";var o;if("number"===i)o=C(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=C(t.length)}var a;Y?a=k(new Uint8Array(o)):(a=this,a.length=o);var u;if(r.isBuffer(t))a.set(t);else if(M(t))for(u=0;o>u;u++)a[u]=r.isBuffer(t)?t.readUInt8(u):t[u];else if("string"===i)a.write(t,0,n);else if("number"===i&&!Y&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,i){e=Number(e)||0;var o=t.length-e;i?(i=Number(i),i>o&&(i=o)):i=o;var a=n.length;if(a%2!==0)throw new Error("Invalid hex string");i>a/2&&(i=a/2);for(var u=0;i>u;u++){var f=parseInt(n.substr(2*u,2),16);if(isNaN(f))throw new Error("Invalid hex string");t[e+u]=f}return r._charsWritten=2*u,u}function o(t,n,e,i){return r._charsWritten=O(N(n),t,e,i)}function a(t,n,e,i){return r._charsWritten=O(D(n),t,e,i)}function u(t,n,e,r){return a(t,n,e,r)}function f(t,n,e,i){return r._charsWritten=O(F(n),t,e,i)}function s(t,n,e){return 0===n&&e===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(n,e))}function c(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)t[o]<=127?(r+=P(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+P(i)}function l(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function h(t,n,e){return l(t,n,e)}function p(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=_(t[o]);return i}function d(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(i>n+1)return t._dataview.getUint16(n,e);var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,t[i-1]),o.getUint16(0,e)}var a;return e?(a=t[n],i>n+1&&(a|=t[n+1]<<8)):(a=t[n]<<8,i>n+1&&(a|=t[n+1])),a}}function g(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(i>n+3)return t._dataview.getUint32(n,e);for(var o=new DataView(new ArrayBuffer(4)),a=0;i>a+n;a++)o.setUint8(a,t[a+n]);return o.getUint32(0,e)}var u;return e?(i>n+2&&(u=t[n+2]<<16),i>n+1&&(u|=t[n+1]<<8),u|=t[n],i>n+3&&(u+=t[n+3]<<24>>>0)):(i>n+1&&(u=t[n+1]<<16),i>n+2&&(u|=t[n+2]<<8),i>n+3&&(u|=t[n+3]),u+=t[n]<<24>>>0),u}}function w(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(n+1===i){var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,t[i-1]),o.getInt16(0,e)}return t._dataview.getInt16(n,e)}var a=d(t,n,e,!0),u=32768&a;return u?-1*(65535-a+1):a}}function b(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(n+3>=i){for(var o=new DataView(new ArrayBuffer(4)),a=0;i>a+n;a++)o.setUint8(a,t[a+n]);return o.getInt32(0,e)}return t._dataview.getInt32(n,e)}var u=g(t,n,e,!0),f=2147483648&u;return f?-1*(4294967295-u+1):u}}function y(t,n,e,r){return r||(R("boolean"==typeof e,"missing or invalid endian"),R(n+3<t.length,"Trying to read beyond buffer length")),Y?t._dataview.getFloat32(n,e):X.read(t,n,e,23,4)}function v(t,n,e,r){return r||(R("boolean"==typeof e,"missing or invalid endian"),R(n+7<t.length,"Trying to read beyond buffer length")),Y?t._dataview.getFloat64(n,e):X.read(t,n,e,52,8)}function m(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"trying to write beyond buffer length"),V(n,65535));var o=t.length;if(!(e>=o))if(Y)if(e+1===o){var a=new DataView(new ArrayBuffer(2));a.setUint16(0,n,r),t[e]=a.getUint8(0)}else t._dataview.setUint16(e,n,r);else for(var u=0,f=Math.min(o-e,2);f>u;u++)t[e+u]=(n&255<<8*(r?u:1-u))>>>8*(r?u:1-u)}function E(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"trying to write beyond buffer length"),V(n,4294967295));var o=t.length;if(!(e>=o)){var a;if(Y)if(e+3>=o){var u=new DataView(new ArrayBuffer(4));for(u.setUint32(0,n,r),a=0;o>a+e;a++)t[a+e]=u.getUint8(a)}else t._dataview.setUint32(e,n,r);else for(a=0,j=Math.min(o-e,4);j>a;a++)t[e+a]=n>>>8*(r?a:3-a)&255}}function I(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"Trying to write beyond buffer length"),q(n,32767,-32768));var o=t.length;if(!(e>=o))if(Y)if(e+1===o){var a=new DataView(new ArrayBuffer(2));a.setInt16(0,n,r),t[e]=a.getUint8(0)}else t._dataview.setInt16(e,n,r);else n>=0?m(t,n,e,r,i):m(t,65535+n+1,e,r,i)}function B(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to write beyond buffer length"),q(n,2147483647,-2147483648));var o=t.length;if(!(e>=o))if(Y)if(e+3>=o){var a=new DataView(new ArrayBuffer(4));a.setInt32(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setInt32(e,n,r);else n>=0?E(t,n,e,r,i):E(t,4294967295+n+1,e,r,i)}function A(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to write beyond buffer length"),J(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(e>=o))if(Y)if(e+3>=o){var a=new DataView(new ArrayBuffer(4));a.setFloat32(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setFloat32(e,n,r);else X.write(t,n,e,r,23,4)}function U(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+7<t.length,"Trying to write beyond buffer length"),J(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(e>=o))if(Y)if(e+7>=o){var a=new DataView(new ArrayBuffer(8));a.setFloat64(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setFloat64(e,n,r);else X.write(t,n,e,r,52,8)}function L(){return new r(this).buffer}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function k(t){return t._isBuffer=!0,t.write=H.write,t.toString=H.toString,t.toLocaleString=H.toString,t.toJSON=H.toJSON,t.copy=H.copy,t.slice=H.slice,t.readUInt8=H.readUInt8,t.readUInt16LE=H.readUInt16LE,t.readUInt16BE=H.readUInt16BE,t.readUInt32LE=H.readUInt32LE,t.readUInt32BE=H.readUInt32BE,t.readInt8=H.readInt8,t.readInt16LE=H.readInt16LE,t.readInt16BE=H.readInt16BE,t.readInt32LE=H.readInt32LE,t.readInt32BE=H.readInt32BE,t.readFloatLE=H.readFloatLE,t.readFloatBE=H.readFloatBE,t.readDoubleLE=H.readDoubleLE,t.readDoubleBE=H.readDoubleBE,t.writeUInt8=H.writeUInt8,t.writeUInt16LE=H.writeUInt16LE,t.writeUInt16BE=H.writeUInt16BE,t.writeUInt32LE=H.writeUInt32LE,t.writeUInt32BE=H.writeUInt32BE,t.writeInt8=H.writeInt8,t.writeInt16LE=H.writeInt16LE,t.writeInt16BE=H.writeInt16BE,t.writeInt32LE=H.writeInt32LE,t.writeInt32BE=H.writeInt32BE,t.writeFloatLE=H.writeFloatLE,t.writeFloatBE=H.writeFloatBE,t.writeDoubleLE=H.writeDoubleLE,t.writeDoubleBE=H.writeDoubleBE,t.fill=H.fill,t.inspect=H.inspect,t.toArrayBuffer=L,0!==t.byteLength&&(t._dataview=new DataView(t.buffer,t.byteOffset,t.byteLength)),t}function S(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function T(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function M(t){return T(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function _(t){return 16>t?"0"+t.toString(16):t.toString(16)}function N(t){for(var n=[],e=0;e<t.length;e++)if(t.charCodeAt(e)<=127)n.push(t.charCodeAt(e));else for(var r=encodeURIComponent(t.charAt(e)).substr(1).split("%"),i=0;i<r.length;i++)n.push(parseInt(r[i],16));return n}function D(t){for(var n=[],e=0;e<t.length;e++)n.push(255&t.charCodeAt(e));return n}function F(t){return W.toByteArray(t)}function O(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function P(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function V(t,n){R("number"==typeof t,"cannot write a non-number as a number"),R(t>=0,"specified a negative value for writing an unsigned value"),R(n>=t,"value is larger than maximum value for type"),R(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){R("number"==typeof t,"cannot write a non-number as a number"),R(n>=t,"value larger than maximum allowed value"),R(t>=e,"value smaller than minimum allowed value"),R(Math.floor(t)===t,"value has a fractional component")}function J(t,n,e){R("number"==typeof t,"cannot write a non-number as a number"),R(n>=t,"value larger than maximum allowed value"),R(t>=e,"value smaller than minimum allowed value")}function R(t,n){if(!t)throw new Error(n||"Failed assertion")}var W=t("base64-js"),X=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192;var Y=function(){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer||"undefined"==typeof DataView)return!1;try{var t=new Uint8Array(0);return t.foo=function(){return 42},42===t.foo()}catch(n){return!1}}();r.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":return!0;default:return!1}},r.isBuffer=function(t){return t&&t._isBuffer},r.byteLength=function(t,n){switch(n||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return N(t).length;case"ascii":case"binary":return t.length;case"base64":return F(t).length;default:throw new Error("Unknown encoding")}},r.concat=function(t,n){if(!T(t))throw new Error("Usage: Buffer.concat(list, [totalLength])\nlist should be an Array.");if(0===t.length)return new r(0);if(1===t.length)return t[0];var e;if("number"!=typeof n)for(n=0,e=0;e<t.length;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;e<t.length;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var s=r;r=n,n=e,e=s}n=Number(n)||0;var c=this.length-n;switch(e?(e=Number(e),e>c&&(e=c)):e=c,r=String(r||"utf8").toLowerCase()){case"hex":return i(this,t,n,e);case"utf8":case"utf-8":return o(this,t,n,e);case"ascii":return a(this,t,n,e);case"binary":return u(this,t,n,e);case"base64":return f(this,t,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toString=function(t,n,e){var r=this;if(t=String(t||"utf8").toLowerCase(),n=Number(n)||0,e=void 0!==e?Number(e):e=r.length,e===n)return"";switch(t){case"hex":return p(r,n,e);case"utf8":case"utf-8":return c(r,n,e);case"ascii":return l(r,n,e);case"binary":return h(r,n,e);case"base64":return s(r,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(t,n,e,r){var i=this;if(e||(e=0),r||0===r||(r=this.length),n||(n=0),r!==e&&0!==t.length&&0!==i.length){if(e>r)throw new Error("sourceEnd < sourceStart");if(0>n||n>=t.length)throw new Error("targetStart out of bounds");if(0>e||e>=i.length)throw new Error("sourceStart out of bounds");if(0>r||r>i.length)throw new Error("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);for(var o=0;r-e>o;o++)t[o+n]=this[o+e]}},r.prototype.slice=function(t,n){var e=this.length;if(t=S(t,e,0),n=S(n,e,e),Y)return k(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,n){var e=this;return n||(R(void 0!==t&&null!==t,"missing offset"),R(t<e.length,"Trying to read beyond buffer length")),t>=e.length?void 0:e[t]},r.prototype.readUInt16LE=function(t,n){return d(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return d(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return g(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return g(this,t,!1,n)},r.prototype.readInt8=function(t,n){var e=this;if(n||(R(void 0!==t&&null!==t,"missing offset"),R(t<e.length,"Trying to read beyond buffer length")),!(t>=e.length)){if(Y)return e._dataview.getInt8(t);var r=128&e[t];return r?-1*(255-e[t]+1):e[t]}},r.prototype.readInt16LE=function(t,n){return w(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return w(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return b(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return b(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return y(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return y(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return v(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return v(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){var r=this;e||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==n&&null!==n,"missing offset"),R(n<r.length,"trying to write beyond buffer length"),V(t,255)),n>=r.length||(r[n]=t)},r.prototype.writeUInt16LE=function(t,n,e){m(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){m(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){E(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){E(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){var r=this;e||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==n&&null!==n,"missing offset"),R(n<r.length,"Trying to write beyond buffer length"),q(t,127,-128)),n>=r.length||(Y?r._dataview.setInt8(n,t):t>=0?r.writeUInt8(t,n,e):r.writeUInt8(255+t+1,n,e))},r.prototype.writeInt16LE=function(t,n,e){I(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){I(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){B(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){B(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){A(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){A(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){U(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){U(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw new Error("value is not a number");if(n>e)throw new Error("end < start");if(e!==n&&0!==this.length){if(0>n||n>=this.length)throw new Error("start out of bounds");if(0>e||e>this.length)throw new Error("end out of bounds");for(var r=n;e>r;r++)this[r]=t}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=_(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"};var H=r.prototype},{"base64-js":3,ieee754:4}],"native-buffer-browserify":[function(t,n){n.exports=t("PcZj9L")},{}],3:[function(t,n){function e(t,n){var e=t.length,r=Number(arguments[1])||0;for(r=0>r?Math.ceil(r):Math.floor(r),0>r&&(r+=e);e>r;r++)if("string"==typeof t&&t.charAt(r)===n||"string"!=typeof t&&t[r]===n)return r;return-1}!function(){"use strict";function t(t){var n,r,o,a,u,f;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(u=e(t,"="),u=u>0?t.length-u:0,f=[],o=u>0?t.length-4:t.length,n=0,r=0;o>n;n+=4,r+=3)a=e(i,t.charAt(n))<<18|e(i,t.charAt(n+1))<<12|e(i,t.charAt(n+2))<<6|e(i,t.charAt(n+3)),f.push((16711680&a)>>16),f.push((65280&a)>>8),f.push(255&a);return 2===u?(a=e(i,t.charAt(n))<<2|e(i,t.charAt(n+1))>>4,f.push(255&a)):1===u&&(a=e(i,t.charAt(n))<<10|e(i,t.charAt(n+1))<<4|e(i,t.charAt(n+2))>>2,f.push(a>>8&255),f.push(255&a)),f}function r(t){function n(t){return i.charAt(t>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t)}var e,r,o,a=t.length%3,u="";for(e=0,o=t.length-a;o>e;e+=3)r=(t[e]<<16)+(t[e+1]<<8)+t[e+2],u+=n(r);switch(a){case 1:r=t[t.length-1],u+=i.charAt(r>>2),u+=i.charAt(r<<4&63),u+="==";break;case 2:r=(t[t.length-2]<<8)+t[t.length-1],u+=i.charAt(r>>10),u+=i.charAt(r>>4&63),u+=i.charAt(r<<2&63),u+="="}return u}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";n.exports.toByteArray=t,n.exports.fromByteArray=r}()},{}],4:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,f=(1<<u)-1,s=f>>1,c=-7,l=e?i-1:0,h=e?-1:1,p=t[n+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[n+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[n+l],l+=h,c-=8);if(0===o)o=1-s;
else{if(o===f)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=s}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,n,e,r,i,o){var a,u,f,s=8*o-i-1,c=(1<<s)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=c):(a=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-a))<1&&(a--,f*=2),n+=a+l>=1?h/f:h*Math.pow(2,1-l),n*f>=2&&(a++,f/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(n*f-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,s+=i;s>0;t[e+p]=255&a,p+=d,a/=256,s-=8);t[e+p-d]|=128*g}},{}]},{},[]),n.exports=t("native-buffer-browserify").Buffer},{}],17:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;if("base64"===n&&"string"===i)for(t=x(t);t.length%4!==0;)t+="=";var o;if("number"===i)o=C(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=C(t.length)}var a;r._useTypedArrays?a=k(new Uint8Array(o)):(a=this,a.length=o);var u;if(r.isBuffer(t))a.set(t);else if(M(t))for(u=0;o>u;u++)a[u]=r.isBuffer(t)?t.readUInt8(u):t[u];else if("string"===i)a.write(t,0,n);else if("number"===i&&!r._useTypedArrays&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,i){e=Number(e)||0;var o=t.length-e;i?(i=Number(i),i>o&&(i=o)):i=o;var a=n.length;J(a%2===0,"Invalid hex string"),i>a/2&&(i=a/2);for(var u=0;i>u;u++){var f=parseInt(n.substr(2*u,2),16);J(!isNaN(f),"Invalid hex string"),t[e+u]=f}return r._charsWritten=2*u,u}function o(t,n,e,i){return r._charsWritten=j(N(n),t,e,i)}function a(t,n,e,i){return r._charsWritten=j(D(n),t,e,i)}function u(t,n,e,r){return a(t,n,e,r)}function f(t,n,e,i){return r._charsWritten=j(F(n),t,e,i)}function s(t,n,e){return 0===n&&e===t.length?R.fromByteArray(t):R.fromByteArray(t.slice(n,e))}function c(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)t[o]<=127?(r+=O(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+O(i)}function l(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function h(t,n,e){return l(t,n,e)}function p(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=_(t[o]);return i}function d(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(o=t[n],i>n+1&&(o|=t[n+1]<<8)):(o=t[n]<<8,i>n+1&&(o|=t[n+1])),o}}function g(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(i>n+2&&(o=t[n+2]<<16),i>n+1&&(o|=t[n+1]<<8),o|=t[n],i>n+3&&(o+=t[n+3]<<24>>>0)):(i>n+1&&(o=t[n+1]<<16),i>n+2&&(o|=t[n+2]<<8),i>n+3&&(o|=t[n+3]),o+=t[n]<<24>>>0),o}}function w(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=d(t,n,e,!0),a=32768&o;return a?-1*(65535-o+1):o}}function b(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=g(t,n,e,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function y(t,n,e,r){return r||(J("boolean"==typeof e,"missing or invalid endian"),J(n+3<t.length,"Trying to read beyond buffer length")),W.read(t,n,e,23,4)}function v(t,n,e,r){return r||(J("boolean"==typeof e,"missing or invalid endian"),J(n+7<t.length,"Trying to read beyond buffer length")),W.read(t,n,e,52,8)}function m(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+1<t.length,"trying to write beyond buffer length"),P(n,65535));var o=t.length;if(!(e>=o))for(var a=0,u=Math.min(o-e,2);u>a;a++)t[e+a]=(n&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function E(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"trying to write beyond buffer length"),P(n,4294967295));var o=t.length;if(!(e>=o))for(var a=0,u=Math.min(o-e,4);u>a;a++)t[e+a]=n>>>8*(r?a:3-a)&255}function I(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+1<t.length,"Trying to write beyond buffer length"),V(n,32767,-32768));var o=t.length;e>=o||(n>=0?m(t,n,e,r,i):m(t,65535+n+1,e,r,i))}function B(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"Trying to write beyond buffer length"),V(n,2147483647,-2147483648));var o=t.length;e>=o||(n>=0?E(t,n,e,r,i):E(t,4294967295+n+1,e,r,i))}function A(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"Trying to write beyond buffer length"),q(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;e>=o||W.write(t,n,e,r,23,4)}function U(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+7<t.length,"Trying to write beyond buffer length"),q(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;e>=o||W.write(t,n,e,r,52,8)}function L(){return new r(this).buffer}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function k(t){return t._isBuffer=!0,t.write=X.write,t.toString=X.toString,t.toLocaleString=X.toString,t.toJSON=X.toJSON,t.copy=X.copy,t.slice=X.slice,t.readUInt8=X.readUInt8,t.readUInt16LE=X.readUInt16LE,t.readUInt16BE=X.readUInt16BE,t.readUInt32LE=X.readUInt32LE,t.readUInt32BE=X.readUInt32BE,t.readInt8=X.readInt8,t.readInt16LE=X.readInt16LE,t.readInt16BE=X.readInt16BE,t.readInt32LE=X.readInt32LE,t.readInt32BE=X.readInt32BE,t.readFloatLE=X.readFloatLE,t.readFloatBE=X.readFloatBE,t.readDoubleLE=X.readDoubleLE,t.readDoubleBE=X.readDoubleBE,t.writeUInt8=X.writeUInt8,t.writeUInt16LE=X.writeUInt16LE,t.writeUInt16BE=X.writeUInt16BE,t.writeUInt32LE=X.writeUInt32LE,t.writeUInt32BE=X.writeUInt32BE,t.writeInt8=X.writeInt8,t.writeInt16LE=X.writeInt16LE,t.writeInt16BE=X.writeInt16BE,t.writeInt32LE=X.writeInt32LE,t.writeInt32BE=X.writeInt32BE,t.writeFloatLE=X.writeFloatLE,t.writeFloatBE=X.writeFloatBE,t.writeDoubleLE=X.writeDoubleLE,t.writeDoubleBE=X.writeDoubleBE,t.fill=X.fill,t.inspect=X.inspect,t.toArrayBuffer=L,t}function S(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function T(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function M(t){return T(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function _(t){return 16>t?"0"+t.toString(16):t.toString(16)}function N(t){for(var n=[],e=0;e<t.length;e++)if(t.charCodeAt(e)<=127)n.push(t.charCodeAt(e));else for(var r=encodeURIComponent(t.charAt(e)).substr(1).split("%"),i=0;i<r.length;i++)n.push(parseInt(r[i],16));return n}function D(t){for(var n=[],e=0;e<t.length;e++)n.push(255&t.charCodeAt(e));return n}function F(t){return R.toByteArray(t)}function j(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function O(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function P(t,n){J("number"==typeof t,"cannot write a non-number as a number"),J(t>=0,"specified a negative value for writing an unsigned value"),J(n>=t,"value is larger than maximum value for type"),J(Math.floor(t)===t,"value has a fractional component")}function V(t,n,e){J("number"==typeof t,"cannot write a non-number as a number"),J(n>=t,"value larger than maximum allowed value"),J(t>=e,"value smaller than minimum allowed value"),J(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){J("number"==typeof t,"cannot write a non-number as a number"),J(n>=t,"value larger than maximum allowed value"),J(t>=e,"value smaller than minimum allowed value")}function J(t,n){if(!t)throw new Error(n||"Failed assertion")}var R=t("base64-js"),W=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer)return!1;try{var t=new Uint8Array(0);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(n){return!1}}(),r.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":return!0;default:return!1}},r.isBuffer=function(t){return t&&t._isBuffer},r.byteLength=function(t,n){switch(n||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return N(t).length;case"ascii":case"binary":return t.length;case"base64":return F(t).length;default:throw new Error("Unknown encoding")}},r.concat=function(t,n){if(J(T(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new r(0);if(1===t.length)return t[0];var e;if("number"!=typeof n)for(n=0,e=0;e<t.length;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;e<t.length;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var s=r;r=n,n=e,e=s}n=Number(n)||0;var c=this.length-n;switch(e?(e=Number(e),e>c&&(e=c)):e=c,r=String(r||"utf8").toLowerCase()){case"hex":return i(this,t,n,e);case"utf8":case"utf-8":return o(this,t,n,e);case"ascii":return a(this,t,n,e);case"binary":return u(this,t,n,e);case"base64":return f(this,t,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toString=function(t,n,e){var r=this;if(t=String(t||"utf8").toLowerCase(),n=Number(n)||0,e=void 0!==e?Number(e):e=r.length,e===n)return"";switch(t){case"hex":return p(r,n,e);case"utf8":case"utf-8":return c(r,n,e);case"ascii":return l(r,n,e);case"binary":return h(r,n,e);case"base64":return s(r,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(t,n,e,r){var i=this;if(e||(e=0),r||0===r||(r=this.length),n||(n=0),r!==e&&0!==t.length&&0!==i.length){J(r>=e,"sourceEnd < sourceStart"),J(n>=0&&n<t.length,"targetStart out of bounds"),J(e>=0&&e<i.length,"sourceStart out of bounds"),J(r>=0&&r<=i.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);for(var o=0;r-e>o;o++)t[o+n]=this[o+e]}},r.prototype.slice=function(t,n){var e=this.length;if(t=S(t,e,0),n=S(n,e,e),r._useTypedArrays)return k(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,n){var e=this;return n||(J(void 0!==t&&null!==t,"missing offset"),J(t<e.length,"Trying to read beyond buffer length")),t>=e.length?void 0:e[t]},r.prototype.readUInt16LE=function(t,n){return d(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return d(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return g(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return g(this,t,!1,n)},r.prototype.readInt8=function(t,n){var e=this;if(n||(J(void 0!==t&&null!==t,"missing offset"),J(t<e.length,"Trying to read beyond buffer length")),!(t>=e.length)){var r=128&e[t];return r?-1*(255-e[t]+1):e[t]}},r.prototype.readInt16LE=function(t,n){return w(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return w(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return b(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return b(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return y(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return y(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return v(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return v(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){var r=this;e||(J(void 0!==t&&null!==t,"missing value"),J(void 0!==n&&null!==n,"missing offset"),J(n<r.length,"trying to write beyond buffer length"),P(t,255)),n>=r.length||(r[n]=t)},r.prototype.writeUInt16LE=function(t,n,e){m(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){m(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){E(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){E(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){var r=this;e||(J(void 0!==t&&null!==t,"missing value"),J(void 0!==n&&null!==n,"missing offset"),J(n<r.length,"Trying to write beyond buffer length"),V(t,127,-128)),n>=r.length||(t>=0?r.writeUInt8(t,n,e):r.writeUInt8(255+t+1,n,e))},r.prototype.writeInt16LE=function(t,n,e){I(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){I(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){B(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){B(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){A(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){A(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){U(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){U(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),J("number"==typeof t&&!isNaN(t),"value is not a number"),J(e>=n,"end < start"),e!==n&&0!==this.length){J(n>=0&&n<this.length,"start out of bounds"),J(e>=0&&e<=this.length,"end out of bounds");for(var r=n;e>r;r++)this[r]=t}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=_(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"};var X=r.prototype},{"base64-js":18,ieee754:19}],18:[function(t,n){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(){"use strict";function t(t){var n=t.charCodeAt(0);return n===a?62:n===u?63:f>n?-1:f+10>n?n-f+26+26:c+26>n?n-c:s+26>n?n-s+26:void 0}function r(n){function e(t){s[l++]=t}var r,i,a,u,f,s;if(n.length%4>0)throw"Invalid string. Length must be a multiple of 4";var c=n.length;f="="===n.charAt(c-2)?2:"="===n.charAt(c-1)?1:0,s=new o(3*n.length/4-f),a=f>0?n.length-4:n.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)u=t(n.charAt(r))<<18|t(n.charAt(r+1))<<12|t(n.charAt(r+2))<<6|t(n.charAt(r+3)),e((16711680&u)>>16),e((65280&u)>>8),e(255&u);return 2===f?(u=t(n.charAt(r))<<2|t(n.charAt(r+1))>>4,e(255&u)):1===f&&(u=t(n.charAt(r))<<10|t(n.charAt(r+1))<<4|t(n.charAt(r+2))>>2,e(u>>8&255),e(255&u)),s}function i(t){function n(t){return e.charAt(t)}function r(t){return n(t>>18&63)+n(t>>12&63)+n(t>>6&63)+n(63&t)}var i,o,a,u=t.length%3,f="";for(i=0,a=t.length-u;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],f+=r(o);switch(u){case 1:o=t[t.length-1],f+=n(o>>2),f+=n(o<<4&63),f+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],f+=n(o>>10),f+=n(o>>4&63),f+=n(o<<2&63),f+="="}return f}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a=("0".charCodeAt(0),"+".charCodeAt(0)),u="/".charCodeAt(0),f="0".charCodeAt(0),s="a".charCodeAt(0),c="A".charCodeAt(0);n.exports.toByteArray=r,n.exports.fromByteArray=i}()},{}],19:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,f=(1<<u)-1,s=f>>1,c=-7,l=e?i-1:0,h=e?-1:1,p=t[n+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[n+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[n+l],l+=h,c-=8);if(0===o)o=1-s;else{if(o===f)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=s}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,n,e,r,i,o){var a,u,f,s=8*o-i-1,c=(1<<s)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=c):(a=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-a))<1&&(a--,f*=2),n+=a+l>=1?h/f:h*Math.pow(2,1-l),n*f>=2&&(a++,f/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(n*f-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,s+=i;s>0;t[e+p]=255&a,p+=d,a/=256,s-=8);t[e+p-d]|=128*g}},{}],20:[function(n,e){var r=n("__browserify_Buffer");(function(){function i(t,n,e){var r=n&&e||0,i=0;for(n=n||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>i&&(n[r+i++]=w[t])});16>i;)n[r+i++]=0;return n}function o(t,n){var e=n||0,r=g;return r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]}function a(t,n,e){var r=n&&e||0,i=n||[];t=t||{};var a=null!=t.clockseq?t.clockseq:m,u=null!=t.msecs?t.msecs:(new Date).getTime(),f=null!=t.nsecs?t.nsecs:I+1,s=u-E+(f-I)/1e4;if(0>s&&null==t.clockseq&&(a=a+1&16383),(0>s||u>E)&&null==t.nsecs&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");E=u,I=f,m=a,u+=122192928e5;var c=(1e4*(268435455&u)+f)%4294967296;i[r++]=c>>>24&255,i[r++]=c>>>16&255,i[r++]=c>>>8&255,i[r++]=255&c;var l=u/4294967296*1e4&268435455;i[r++]=l>>>8&255,i[r++]=255&l,i[r++]=l>>>24&15|16,i[r++]=l>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var h=t.node||v,p=0;6>p;p++)i[r+p]=h[p];return n?n:o(i)}function u(t,n,e){var r=n&&e||0;"string"==typeof t&&(n="binary"==t?new d(16):null,t=null),t=t||{};var i=t.random||(t.rng||f)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,n)for(var a=0;16>a;a++)n[r+a]=i[a];return n||o(i)}var f,s=this;if("function"==typeof n)try{var c=n("crypto").randomBytes;f=c&&function(){return c(16)}}catch(l){}if(!f&&s.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);f=function(){return crypto.getRandomValues(h),h}}if(!f){var p=new Array(16);f=function(){for(var t,n=0;16>n;n++)0===(3&n)&&(t=4294967296*Math.random()),p[n]=t>>>((3&n)<<3)&255;return p}}for(var d="function"==typeof r?r:Array,g=[],w={},b=0;256>b;b++)g[b]=(b+256).toString(16).substr(1),w[g[b]]=b;var y=f(),v=[1|y[0],y[1],y[2],y[3],y[4],y[5]],m=16383&(y[6]<<8|y[7]),E=0,I=0,B=u;if(B.v1=a,B.v4=u,B.parse=i,B.unparse=o,B.BufferClass=d,"function"==typeof t&&t.amd)t(function(){return B});else if("undefined"!=typeof e&&e.exports)e.exports=B;else{var A=s.uuid;B.noConflict=function(){return s.uuid=A,B},s.uuid=B}}).call(this)},{__browserify_Buffer:16,crypto:11}],21:[function(n,e,r){!function(n,i){"use strict";"object"==typeof r&&e?e.exports=i():"function"==typeof t&&t.amd?t(i):n.PubSub=i()}("object"==typeof window&&window||this,function(){"use strict";function t(t){return function(){throw t}}function n(n,e,r){try{n(e,r)}catch(i){setTimeout(t(i),0)}}function e(t,n,e){t(n,e)}function r(t,r,i,o){var a,u=f[r],s=o?e:n;if(f.hasOwnProperty(r))for(a=0;a<u.length;a++)s(u[a].func,t,i)}function i(t,n,e){return function(){var i=String(t),o=i.lastIndexOf(".");for(r(t,t,n,e);-1!==o;)i=i.substr(0,o),o=i.lastIndexOf("."),r(t,i,n)}}function o(t){for(var n=String(t),e=f.hasOwnProperty(n),r=n.lastIndexOf(".");!e&&-1!==r;)n=n.substr(0,r),r=n.lastIndexOf("."),e=f.hasOwnProperty(n);return e&&f[n].length>0}function a(t,n,e,r){var a=i(t,n,r),u=o(t);return u?(e===!0?a():setTimeout(a,0),!0):!1}var u={},f={},s=-1;return u.publish=function(t,n){return a(t,n,!1,u.immediateExceptions)},u.publishSync=function(t,n){return a(t,n,!0,u.immediateExceptions)},u.subscribe=function(t,n){if("function"!=typeof n)return!1;f.hasOwnProperty(t)||(f[t]=[]);var e=String(++s);return f[t].push({token:e,func:n}),e},u.unsubscribe=function(t){var n,e,r="string"==typeof t,i=r?"token":"func",o=r?t:!0,a=!1;for(n in f)if(f.hasOwnProperty(n))for(e=f[n].length-1;e>=0;e--)if(f[n][e][i]===t&&(f[n].splice(e,1),a=o,r))return a;return a},u})},{}]},{},[1])(1)});
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.babble=t()}}(function(){var t;return function n(t,e,r){function o(u,a){if(!e[u]){if(!t[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=e[u]={exports:{}};t[u][0].call(c.exports,function(n){var e=t[u][1][n];return o(e?e:n)},c,c.exports,n,t,e,r)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(t,n){n.exports=t("./lib/babble")},{"./lib/babble":3}],2:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(!t)throw new Error("id required");this.id=t,this.listeners={},this.conversations={}}var r=t("node-uuid"),o=t("./messagers"),i=(t("./block/Block"),t("./block/Action"),t("./block/Tell")),u=t("./block/Listen");e.prototype.connect=function(t,n){if("function"==typeof t&&(n=t,t=null),t||(t=o["default"]()),"function"!=typeof t.connect)throw new Error("messager must contain a function connect(params: {id: string, callback: function}) : function");if("function"!=typeof t.send)throw new Error("messager must contain a function send(params: {id: string, message: *})");var e=this,r=t.connect({id:this.id,message:function(t){var n,r,o=JSON.parse(t.message);n=e.conversations[t.id],n?e._run(n,o):(r=e.listeners[o],r&&(n={id:t.id,peer:t.from,next:r,context:{from:t.from}},e._run(n,o)))},connect:n});if("function"!=typeof r)throw new Error("messager.connect must return a function to disconnect");return this.disconnect=r,this.send=t.send,this},e.prototype.disconnect=function(){throw new Error("Cannot disconnect: not connected")},e.prototype.send=function(){throw new Error("Cannot send: not connected")},e.prototype.listen=function a(t,n){if("string"!=typeof t)throw new TypeError("Parameter message must be a string");var a=new u(n);return this.listeners[t]=a,a},e.prototype.tell=function(t,n){var e=r.v4(),o=new i,a={id:e,peer:t,next:o,context:{from:t}},s=this;return o.then=function c(t){return a.next=t,t instanceof u?s.conversations[e]=a:(n=s._run(a,n),t.then=c),t},n=this._run(a,n),o},e.prototype.ask=function(t,n,e){return this.tell(t,n).listen(e)},e.prototype._run=function(t,n){delete this.conversations[t.id];var e=t.next;do{var r=e.execute(n,t.context);n=r.result,e instanceof i&&this.send(t.peer,{id:t.id,from:this.id,to:t.peer,message:JSON.stringify(n)}),e=r.block,e instanceof u&&(t.next=e,this.conversations[t.id]=t)}while(e&&!(e instanceof u));return n},n.exports=e},{"./block/Action":4,"./block/Block":5,"./block/Listen":7,"./block/Tell":8,"./messagers":9,"node-uuid":19}],3:[function(t,n,e){var r=t("./Babbler"),o=t("./block/Tell"),i=t("./block/Action"),u=t("./block/Decision");e.babbler=function(t){return new r(t)},e.tell=function(t){var n="function"==typeof t?t:function(){return t};return new o(n)},e.decide=function(t,n){return new u(t,n)},e.run=function(t){return new i(t)},e.Babbler=r,e.block={Block:t("./block/Block"),Action:t("./block/Action"),Decision:t("./block/Decision"),Listen:t("./block/Listen"),Tell:t("./block/Tell")},e.messagers=t("./messagers")},{"./Babbler":2,"./block/Action":4,"./block/Block":5,"./block/Decision":6,"./block/Listen":7,"./block/Tell":8,"./messagers":9}],4:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if("function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.run=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],5:[function(t,n){function e(){this.next=null,this.previous=null}e.prototype.execute=function(){throw new Error("Cannot run an abstract Block")},e.prototype.then=function(t){if(!(t instanceof e))throw new TypeError("Parameter next must be a Block");for(var n=this;n.next;)n=n.next;for(var r=this;r.previous;)r=r.previous;return t.previous=this,n.next=t,r},n.exports=e},{}],6:[function(t,n){function e(t,n){var r,o;if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if("function"==typeof t?(r=t,o=n):(r=null,o=t),r){if("function"!=typeof r)throw new TypeError("Parameter decision must be a function")}else r=function(t){return t};if(o&&o instanceof Function)throw new TypeError("Parameter choices must be an object");if(this.decision=r,this.choices={},o){var i=this;Object.keys(o).forEach(function(t){i.addChoice(t,o[t])})}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.decision(t,n);if("string"!=typeof e)throw new TypeError("Decision function must return a string containing the id of the next block");var r=this.choices[e];if(!r)throw new Error('Block with id "'+e+'" not found');return{result:t,block:r}},e.prototype.addChoice=function(t,n){if("string"!=typeof t)throw new TypeError("String expected as choice id");if(!(n instanceof r))throw new TypeError("Block expected as choice");if(t in this.choices)throw new Error('Choice with id "'+t+'" already exists');return this.choices[t]=n,this},r.prototype.decide=function(t,n){var r=new e(t,n);return this.then(r)},n.exports=e},{"./Block":5}],7:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(t&&"function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t||function(t){return t}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.listen=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],8:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(t&&"function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t||function(t){return t}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.tell=function(t){var n="function"==typeof t?t:function(){return t},r=new e(n);return this.then(r)},n.exports=e},{"./Block":5}],9:[function(t,n,e){e["pubsub-js"]=function(){var n=t("pubsub-js");return{connect:function(t){var e=n.subscribe(t.id,function(n,e){t.message(e)});return"function"==typeof t.connect&&t.connect(),function(){n.unsubscribe(e)}},send:function(t,e){n.publish(t,e)}}},e.pubnub=function(n){var e;if("undefined"!=typeof window){if("undefined"==typeof window.PUBNUB)throw new Error("Please load pubnub first in the browser");e=window.PUBNUB}else e=t("pubnub");var r=e.init(n);return{connect:function(t){return r.subscribe({channel:t.id,message:t.message,connect:t.connect}),function(){r.unsubscribe(t.id)}},send:function(t,n){r.publish({channel:t,message:n})}}},e["default"]=e["pubsub-js"]},{pubnub:"55flJj","pubsub-js":20}],10:[function(t,n){function e(t,n){if(t.length%u!==0){var e=t.length+(u-t.length%u);t=i.concat([t,a],e)}for(var r=[],o=n?t.readInt32BE:t.readInt32LE,s=0;s<t.length;s+=u)r.push(o.call(t,s));return r}function r(t,n,e){for(var r=new i(n),o=e?r.writeInt32BE:r.writeInt32LE,u=0;u<t.length;u++)o.call(r,t[u],4*u,!0);return r}function o(t,n,o,u){i.isBuffer(t)||(t=new i(t));var a=n(e(t,u),t.length*s);return r(a,o,u)}var i=t("buffer").Buffer,u=4,a=new i(u);a.fill(0);var s=8;n.exports={hash:o}},{buffer:16}],11:[function(t,n,e){function r(t,n,e){a.isBuffer(n)||(n=new a(n)),a.isBuffer(e)||(e=new a(e)),n.length>p?n=t(n):n.length<p&&(n=a.concat([n,d],p));for(var r=new a(p),o=new a(p),i=0;p>i;i++)r[i]=54^n[i],o[i]=92^n[i];var u=t(a.concat([r,e]));return t(a.concat([o,u]))}function o(t,n){t=t||"sha1";var e=h[t],o=[],u=0;return e||i("algorithm:",t,"is not yet supported"),{update:function(t){return a.isBuffer(t)||(t=new a(t)),o.push(t),u+=t.length,this},digest:function(t){var i=a.concat(o),u=n?r(e,n,i):e(i);return o=null,t?u.toString(t):u}}}function i(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function u(t,n){for(var e in t)n(t[e],e)}var a=t("buffer").Buffer,s=t("./sha"),c=t("./sha256"),f=t("./rng"),l=t("./md5"),h={sha1:s,sha256:c,md5:l},p=64,d=new a(p);d.fill(0),e.createHash=function(t){return o(t)},e.createHmac=function(t,n){return o(t,n)},e.randomBytes=function(t,n){if(!n||!n.call)return new a(f(t));try{n.call(this,void 0,new a(f(t)))}catch(e){n(e)}},u(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(t){e[t]=function(){i("sorry,",t,"is not implemented yet")}})},{"./md5":12,"./rng":13,"./sha":14,"./sha256":15,buffer:16}],12:[function(t,n){function e(t,n){t[n>>5]|=128<<n%32,t[(n+64>>>9<<4)+14]=n;for(var e=1732584193,r=-271733879,c=-1732584194,f=271733878,l=0;l<t.length;l+=16){var h=e,p=r,d=c,y=f;e=o(e,r,c,f,t[l+0],7,-680876936),f=o(f,e,r,c,t[l+1],12,-389564586),c=o(c,f,e,r,t[l+2],17,606105819),r=o(r,c,f,e,t[l+3],22,-1044525330),e=o(e,r,c,f,t[l+4],7,-176418897),f=o(f,e,r,c,t[l+5],12,1200080426),c=o(c,f,e,r,t[l+6],17,-1473231341),r=o(r,c,f,e,t[l+7],22,-45705983),e=o(e,r,c,f,t[l+8],7,1770035416),f=o(f,e,r,c,t[l+9],12,-1958414417),c=o(c,f,e,r,t[l+10],17,-42063),r=o(r,c,f,e,t[l+11],22,-1990404162),e=o(e,r,c,f,t[l+12],7,1804603682),f=o(f,e,r,c,t[l+13],12,-40341101),c=o(c,f,e,r,t[l+14],17,-1502002290),r=o(r,c,f,e,t[l+15],22,1236535329),e=i(e,r,c,f,t[l+1],5,-165796510),f=i(f,e,r,c,t[l+6],9,-1069501632),c=i(c,f,e,r,t[l+11],14,643717713),r=i(r,c,f,e,t[l+0],20,-373897302),e=i(e,r,c,f,t[l+5],5,-701558691),f=i(f,e,r,c,t[l+10],9,38016083),c=i(c,f,e,r,t[l+15],14,-660478335),r=i(r,c,f,e,t[l+4],20,-405537848),e=i(e,r,c,f,t[l+9],5,568446438),f=i(f,e,r,c,t[l+14],9,-1019803690),c=i(c,f,e,r,t[l+3],14,-187363961),r=i(r,c,f,e,t[l+8],20,1163531501),e=i(e,r,c,f,t[l+13],5,-1444681467),f=i(f,e,r,c,t[l+2],9,-51403784),c=i(c,f,e,r,t[l+7],14,1735328473),r=i(r,c,f,e,t[l+12],20,-1926607734),e=u(e,r,c,f,t[l+5],4,-378558),f=u(f,e,r,c,t[l+8],11,-2022574463),c=u(c,f,e,r,t[l+11],16,1839030562),r=u(r,c,f,e,t[l+14],23,-35309556),e=u(e,r,c,f,t[l+1],4,-1530992060),f=u(f,e,r,c,t[l+4],11,1272893353),c=u(c,f,e,r,t[l+7],16,-155497632),r=u(r,c,f,e,t[l+10],23,-1094730640),e=u(e,r,c,f,t[l+13],4,681279174),f=u(f,e,r,c,t[l+0],11,-358537222),c=u(c,f,e,r,t[l+3],16,-722521979),r=u(r,c,f,e,t[l+6],23,76029189),e=u(e,r,c,f,t[l+9],4,-640364487),f=u(f,e,r,c,t[l+12],11,-421815835),c=u(c,f,e,r,t[l+15],16,530742520),r=u(r,c,f,e,t[l+2],23,-995338651),e=a(e,r,c,f,t[l+0],6,-198630844),f=a(f,e,r,c,t[l+7],10,1126891415),c=a(c,f,e,r,t[l+14],15,-1416354905),r=a(r,c,f,e,t[l+5],21,-57434055),e=a(e,r,c,f,t[l+12],6,1700485571),f=a(f,e,r,c,t[l+3],10,-1894986606),c=a(c,f,e,r,t[l+10],15,-1051523),r=a(r,c,f,e,t[l+1],21,-2054922799),e=a(e,r,c,f,t[l+8],6,1873313359),f=a(f,e,r,c,t[l+15],10,-30611744),c=a(c,f,e,r,t[l+6],15,-1560198380),r=a(r,c,f,e,t[l+13],21,1309151649),e=a(e,r,c,f,t[l+4],6,-145523070),f=a(f,e,r,c,t[l+11],10,-1120210379),c=a(c,f,e,r,t[l+2],15,718787259),r=a(r,c,f,e,t[l+9],21,-343485551),e=s(e,h),r=s(r,p),c=s(c,d),f=s(f,y)}return Array(e,r,c,f)}function r(t,n,e,r,o,i){return s(c(s(s(n,t),s(r,i)),o),e)}function o(t,n,e,o,i,u,a){return r(n&e|~n&o,t,n,i,u,a)}function i(t,n,e,o,i,u,a){return r(n&o|e&~o,t,n,i,u,a)}function u(t,n,e,o,i,u,a){return r(n^e^o,t,n,i,u,a)}function a(t,n,e,o,i,u,a){return r(e^(n|~o),t,n,i,u,a)}function s(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function c(t,n){return t<<n|t>>>32-n}var f=t("./helpers");n.exports=function(t){return f.hash(t,e,16)}},{"./helpers":10}],13:[function(t,n){!function(){var t,e,r=this;t=function(t){for(var n,n,e=new Array(t),r=0;t>r;r++)0==(3&r)&&(n=4294967296*Math.random()),e[r]=n>>>((3&r)<<3)&255;return e},r.crypto&&crypto.getRandomValues&&(e=function(t){var n=new Uint8Array(t);return crypto.getRandomValues(n),n}),n.exports=e||t}()},{}],14:[function(t,n){function e(t,n){t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var e=Array(80),a=1732584193,s=-271733879,c=-1732584194,f=271733878,l=-1009589776,h=0;h<t.length;h+=16){for(var p=a,d=s,y=c,g=f,b=l,w=0;80>w;w++){e[w]=16>w?t[h+w]:u(e[w-3]^e[w-8]^e[w-14]^e[w-16],1);var v=i(i(u(a,5),r(w,s,c,f)),i(i(l,e[w]),o(w)));l=f,f=c,c=u(s,30),s=a,a=v}a=i(a,p),s=i(s,d),c=i(c,y),f=i(f,g),l=i(l,b)}return Array(a,s,c,f,l)}function r(t,n,e,r){return 20>t?n&e|~n&r:40>t?n^e^r:60>t?n&e|n&r|e&r:n^e^r}function o(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function i(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function u(t,n){return t<<n|t>>>32-n}var a=t("./helpers");n.exports=function(t){return a.hash(t,e,20,!0)}},{"./helpers":10}],15:[function(t,n){var e=t("./helpers"),r=function(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e},o=function(t,n){return t>>>n|t<<32-n},i=function(t,n){return t>>>n},u=function(t,n,e){return t&n^~t&e},a=function(t,n,e){return t&n^t&e^n&e},s=function(t){return o(t,2)^o(t,13)^o(t,22)},c=function(t){return o(t,6)^o(t,11)^o(t,25)},f=function(t){return o(t,7)^o(t,18)^i(t,3)},l=function(t){return o(t,17)^o(t,19)^i(t,10)},h=function(t,n){var e,o,i,h,p,d,y,g,b,w,v,m,E=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),B=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),I=new Array(64);t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var b=0;b<t.length;b+=16){e=B[0],o=B[1],i=B[2],h=B[3],p=B[4],d=B[5],y=B[6],g=B[7];for(var w=0;64>w;w++)I[w]=16>w?t[w+b]:r(r(r(l(I[w-2]),I[w-7]),f(I[w-15])),I[w-16]),v=r(r(r(r(g,c(p)),u(p,d,y)),E[w]),I[w]),m=r(s(e),a(e,o,i)),g=y,y=d,d=p,p=r(h,v),h=i,i=o,o=e,e=r(v,m);B[0]=r(e,B[0]),B[1]=r(o,B[1]),B[2]=r(i,B[2]),B[3]=r(h,B[3]),B[4]=r(p,B[4]),B[5]=r(d,B[5]),B[6]=r(y,B[6]),B[7]=r(g,B[7])}return B};n.exports=function(t){return e.hash(t,h,32,!0)}},{"./helpers":10}],16:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var o=typeof t;if("base64"===n&&"string"===o)for(t=x(t);t.length%4!==0;)t+="=";var i;if("number"===o)i=C(t);else if("string"===o)i=r.byteLength(t,n);else{if("object"!==o)throw new Error("First argument needs to be a number, array or string.");i=C(t.length)}var u;r._useTypedArrays?u=U(new Uint8Array(i)):(u=this,u.length=i,u._isBuffer=!0);var a;if(r._useTypedArrays&&"function"==typeof Uint8Array&&t instanceof Uint8Array)u._set(t);else if(T(t))for(a=0;i>a;a++)u[a]=r.isBuffer(t)?t.readUInt8(a):t[a];else if("string"===o)u.write(t,0,n);else if("number"===o&&!r._useTypedArrays&&!e)for(a=0;i>a;a++)u[a]=0;return u}function o(t,n,e,o){e=Number(e)||0;var i=t.length-e;o?(o=Number(o),o>i&&(o=i)):o=i;var u=n.length;J(u%2===0,"Invalid hex string"),o>u/2&&(o=u/2);for(var a=0;o>a;a++){var s=parseInt(n.substr(2*a,2),16);J(!isNaN(s),"Invalid hex string"),t[e+a]=s}return r._charsWritten=2*a,a}function i(t,n,e,o){var i=r._charsWritten=O(M(n),t,e,o);return i}function u(t,n,e,o){var i=r._charsWritten=O(N(n),t,e,o);return i}function a(t,n,e,r){return u(t,n,e,r)}function s(t,n,e,o){var i=r._charsWritten=O(j(n),t,e,o);return i}function c(t,n,e){return R.fromByteArray(0===n&&e===t.length?t:t.slice(n,e))}function f(t,n,e){var r="",o="";e=Math.min(t.length,e);for(var i=n;e>i;i++)t[i]<=127?(r+=D(o)+String.fromCharCode(t[i]),o=""):o+="%"+t[i].toString(16);return r+D(o)}function l(t,n,e){var r="";e=Math.min(t.length,e);for(var o=n;e>o;o++)r+=String.fromCharCode(t[o]);return r}function h(t,n,e){return l(t,n,e)}function p(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var o="",i=n;e>i;i++)o+=_(t[i]);return o}function d(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+1<t.length,"Trying to read beyond buffer length"));var o=t.length;if(!(n>=o)){var i;return e?(i=t[n],o>n+1&&(i|=t[n+1]<<8)):(i=t[n]<<8,o>n+1&&(i|=t[n+1])),i}}function y(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+3<t.length,"Trying to read beyond buffer length"));var o=t.length;if(!(n>=o)){var i;return e?(o>n+2&&(i=t[n+2]<<16),o>n+1&&(i|=t[n+1]<<8),i|=t[n],o>n+3&&(i+=t[n+3]<<24>>>0)):(o>n+1&&(i=t[n+1]<<16),o>n+2&&(i|=t[n+2]<<8),o>n+3&&(i|=t[n+3]),i+=t[n]<<24>>>0),i}}function g(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+1<t.length,"Trying to read beyond buffer length"));var o=t.length;if(!(n>=o)){var i=d(t,n,e,!0),u=32768&i;return u?-1*(65535-i+1):i}}function b(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+3<t.length,"Trying to read beyond buffer length"));var o=t.length;if(!(n>=o)){var i=y(t,n,e,!0),u=2147483648&i;return u?-1*(4294967295-i+1):i}}function w(t,n,e,r){return r||(J("boolean"==typeof e,"missing or invalid endian"),J(n+3<t.length,"Trying to read beyond buffer length")),V.read(t,n,e,23,4)}function v(t,n,e,r){return r||(J("boolean"==typeof e,"missing or invalid endian"),J(n+7<t.length,"Trying to read beyond buffer length")),V.read(t,n,e,52,8)}function m(t,n,e,r,o){o||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+1<t.length,"trying to write beyond buffer length"),P(n,65535));var i=t.length;if(!(e>=i))for(var u=0,a=Math.min(i-e,2);a>u;u++)t[e+u]=(n&255<<8*(r?u:1-u))>>>8*(r?u:1-u)}function E(t,n,e,r,o){o||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"trying to write beyond buffer length"),P(n,4294967295));var i=t.length;if(!(e>=i))for(var u=0,a=Math.min(i-e,4);a>u;u++)t[e+u]=n>>>8*(r?u:3-u)&255}function B(t,n,e,r,o){o||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+1<t.length,"Trying to write beyond buffer length"),F(n,32767,-32768));var i=t.length;e>=i||(n>=0?m(t,n,e,r,o):m(t,65535+n+1,e,r,o))}function I(t,n,e,r,o){o||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"Trying to write beyond buffer length"),F(n,2147483647,-2147483648));var i=t.length;e>=i||(n>=0?E(t,n,e,r,o):E(t,4294967295+n+1,e,r,o))}function A(t,n,e,r,o){o||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"Trying to write beyond buffer length"),q(n,3.4028234663852886e38,-3.4028234663852886e38));var i=t.length;e>=i||V.write(t,n,e,r,23,4)}function k(t,n,e,r,o){o||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+7<t.length,"Trying to write beyond buffer length"),q(n,1.7976931348623157e308,-1.7976931348623157e308));var i=t.length;e>=i||V.write(t,n,e,r,52,8)}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function U(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=W.get,t.set=W.set,t.write=W.write,t.toString=W.toString,t.toLocaleString=W.toString,t.toJSON=W.toJSON,t.copy=W.copy,t.slice=W.slice,t.readUInt8=W.readUInt8,t.readUInt16LE=W.readUInt16LE,t.readUInt16BE=W.readUInt16BE,t.readUInt32LE=W.readUInt32LE,t.readUInt32BE=W.readUInt32BE,t.readInt8=W.readInt8,t.readInt16LE=W.readInt16LE,t.readInt16BE=W.readInt16BE,t.readInt32LE=W.readInt32LE,t.readInt32BE=W.readInt32BE,t.readFloatLE=W.readFloatLE,t.readFloatBE=W.readFloatBE,t.readDoubleLE=W.readDoubleLE,t.readDoubleBE=W.readDoubleBE,t.writeUInt8=W.writeUInt8,t.writeUInt16LE=W.writeUInt16LE,t.writeUInt16BE=W.writeUInt16BE,t.writeUInt32LE=W.writeUInt32LE,t.writeUInt32BE=W.writeUInt32BE,t.writeInt8=W.writeInt8,t.writeInt16LE=W.writeInt16LE,t.writeInt16BE=W.writeInt16BE,t.writeInt32LE=W.writeInt32LE,t.writeInt32BE=W.writeInt32BE,t.writeFloatLE=W.writeFloatLE,t.writeFloatBE=W.writeFloatBE,t.writeDoubleLE=W.writeDoubleLE,t.writeDoubleBE=W.writeDoubleBE,t.fill=W.fill,t.inspect=W.inspect,t.toArrayBuffer=W.toArrayBuffer,t}function L(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function S(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function T(t){return S(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function _(t){return 16>t?"0"+t.toString(16):t.toString(16)}function M(t){for(var n=[],e=0;e<t.length;e++){var r=t.charCodeAt(e);if(127>=r)n.push(t.charCodeAt(e));else{var o=e;r>=55296&&57343>=r&&e++;for(var i=encodeURIComponent(t.slice(o,e+1)).substr(1).split("%"),u=0;u<i.length;u++)n.push(parseInt(i[u],16))}}return n}function N(t){for(var n=[],e=0;e<t.length;e++)n.push(255&t.charCodeAt(e));return n}function j(t){return R.toByteArray(t)}function O(t,n,e,r){for(var o=0;r>o&&!(o+e>=n.length||o>=t.length);o++)n[o+e]=t[o];return o}function D(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function P(t,n){J("number"==typeof t,"cannot write a non-number as a number"),J(t>=0,"specified a negative value for writing an unsigned value"),J(n>=t,"value is larger than maximum value for type"),J(Math.floor(t)===t,"value has a fractional component")}function F(t,n,e){J("number"==typeof t,"cannot write a non-number as a number"),J(n>=t,"value larger than maximum allowed value"),J(t>=e,"value smaller than minimum allowed value"),J(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){J("number"==typeof t,"cannot write a non-number as a number"),J(n>=t,"value larger than maximum allowed value"),J(t>=e,"value smaller than minimum allowed value")}function J(t,n){if(!t)throw new Error(n||"Failed assertion")}var R=t("base64-js"),V=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer)return!1;try{var t=new Uint8Array(0);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(n){return!1}}(),r.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(t){return!(null===t||void 0===t||!t._isBuffer)},r.byteLength=function(t,n){var e;switch(t+="",n||"utf8"){case"hex":e=t.length/2;break;case"utf8":case"utf-8":e=M(t).length;break;case"ascii":case"binary":case"raw":e=t.length;break;case"base64":e=j(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=2*t.length;break;default:throw new Error("Unknown encoding")}return e},r.concat=function(t,n){if(J(S(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new r(0);if(1===t.length)return t[0];var e;if("number"!=typeof n)for(n=0,e=0;e<t.length;e++)n+=t[e].length;var o=new r(n),i=0;for(e=0;e<t.length;e++){var u=t[e];u.copy(o,i),i+=u.length}return o},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var c=r;r=n,n=e,e=c}n=Number(n)||0;var f=this.length-n;switch(e?(e=Number(e),e>f&&(e=f)):e=f,r=String(r||"utf8").toLowerCase()){case"hex":return o(this,t,n,e);case"utf8":case"utf-8":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i(this,t,n,e);case"ascii":return u(this,t,n,e);case"binary":return a(this,t,n,e);case"base64":return s(this,t,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toString=function(t,n,e){var r=this;if(t=String(t||"utf8").toLowerCase(),n=Number(n)||0,e=void 0!==e?Number(e):e=r.length,e===n)return"";switch(t){case"hex":return p(r,n,e);case"utf8":case"utf-8":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return f(r,n,e);case"ascii":return l(r,n,e);case"binary":return h(r,n,e);case"base64":return c(r,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(t,n,e,r){var o=this;if(e||(e=0),r||0===r||(r=this.length),n||(n=0),r!==e&&0!==t.length&&0!==o.length){J(r>=e,"sourceEnd < sourceStart"),J(n>=0&&n<t.length,"targetStart out of bounds"),J(e>=0&&e<o.length,"sourceStart out of bounds"),J(r>=0&&r<=o.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);for(var i=0;r-e>i;i++)t[i+n]=this[i+e]}},r.prototype.slice=function(t,n){var e=this.length;if(t=L(t,e,0),n=L(n,e,e),r._useTypedArrays)return U(this.subarray(t,n));for(var o=n-t,i=new r(o,void 0,!0),u=0;o>u;u++)i[u]=this[u+t];return i},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,n){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,n)},r.prototype.readUInt8=function(t,n){return n||(J(void 0!==t&&null!==t,"missing offset"),J(t<this.length,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,n){return d(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return d(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return y(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return y(this,t,!1,n)},r.prototype.readInt8=function(t,n){if(n||(J(void 0!==t&&null!==t,"missing offset"),J(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length)){var e=128&this[t];return e?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,n){return g(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return g(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return b(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return b(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return w(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return w(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return v(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return v(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){e||(J(void 0!==t&&null!==t,"missing value"),J(void 0!==n&&null!==n,"missing offset"),J(n<this.length,"trying to write beyond buffer length"),P(t,255)),n>=this.length||(this[n]=t)},r.prototype.writeUInt16LE=function(t,n,e){m(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){m(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){E(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){E(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){e||(J(void 0!==t&&null!==t,"missing value"),J(void 0!==n&&null!==n,"missing offset"),J(n<this.length,"Trying to write beyond buffer length"),F(t,127,-128)),n>=this.length||(t>=0?this.writeUInt8(t,n,e):this.writeUInt8(255+t+1,n,e))},r.prototype.writeInt16LE=function(t,n,e){B(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){B(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){I(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){I(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){A(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){A(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){k(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){k(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),J("number"==typeof t&&!isNaN(t),"value is not a number"),J(e>=n,"end < start"),e!==n&&0!==this.length){J(n>=0&&n<this.length,"start out of bounds"),J(e>=0&&e<=this.length,"end out of bounds");for(var r=n;e>r;r++)this[r]=t}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=_(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("function"==typeof Uint8Array){if(r._useTypedArrays)return new r(this).buffer;for(var t=new Uint8Array(this.length),n=0,e=t.length;e>n;n+=1)t[n]=this[n];return t.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var W=r.prototype},{"base64-js":17,ieee754:18}],17:[function(t,n){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(){"use strict";function t(t){var n=t.charCodeAt(0);return n===u?62:n===a?63:s>n?-1:s+10>n?n-s+26+26:f+26>n?n-f:c+26>n?n-c+26:void 0}function r(n){function e(t){c[l++]=t}var r,o,u,a,s,c;if(n.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=n.length;s="="===n.charAt(f-2)?2:"="===n.charAt(f-1)?1:0,c=new i(3*n.length/4-s),u=s>0?n.length-4:n.length;var l=0;for(r=0,o=0;u>r;r+=4,o+=3)a=t(n.charAt(r))<<18|t(n.charAt(r+1))<<12|t(n.charAt(r+2))<<6|t(n.charAt(r+3)),e((16711680&a)>>16),e((65280&a)>>8),e(255&a);return 2===s?(a=t(n.charAt(r))<<2|t(n.charAt(r+1))>>4,e(255&a)):1===s&&(a=t(n.charAt(r))<<10|t(n.charAt(r+1))<<4|t(n.charAt(r+2))>>2,e(a>>8&255),e(255&a)),c}function o(t){function n(t){return e.charAt(t)}function r(t){return n(t>>18&63)+n(t>>12&63)+n(t>>6&63)+n(63&t)}var o,i,u,a=t.length%3,s="";for(o=0,u=t.length-a;u>o;o+=3)i=(t[o]<<16)+(t[o+1]<<8)+t[o+2],s+=r(i);switch(a){case 1:i=t[t.length-1],s+=n(i>>2),s+=n(i<<4&63),s+="==";break;case 2:i=(t[t.length-2]<<8)+t[t.length-1],s+=n(i>>10),s+=n(i>>4&63),s+=n(i<<2&63),s+="="}return s}var i="undefined"!=typeof Uint8Array?Uint8Array:Array,u=("0".charCodeAt(0),"+".charCodeAt(0)),a="/".charCodeAt(0),s="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);n.exports.toByteArray=r,n.exports.fromByteArray=o}()},{}],18:[function(t,n,e){e.read=function(t,n,e,r,o){var i,u,a=8*o-r-1,s=(1<<a)-1,c=s>>1,f=-7,l=e?o-1:0,h=e?-1:1,p=t[n+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[n+l],l+=h,f-=8);for(u=i&(1<<-f)-1,i>>=-f,f+=r;f>0;u=256*u+t[n+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===s)return u?0/0:1/0*(p?-1:1);u+=Math.pow(2,r),i-=c}return(p?-1:1)*u*Math.pow(2,i-r)},e.write=function(t,n,e,r,o,i){var u,a,s,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(a=isNaN(n)?1:0,u=f):(u=Math.floor(Math.log(n)/Math.LN2),n*(s=Math.pow(2,-u))<1&&(u--,s*=2),n+=u+l>=1?h/s:h*Math.pow(2,1-l),n*s>=2&&(u++,s/=2),u+l>=f?(a=0,u=f):u+l>=1?(a=(n*s-1)*Math.pow(2,o),u+=l):(a=n*Math.pow(2,l-1)*Math.pow(2,o),u=0));o>=8;t[e+p]=255&a,p+=d,a/=256,o-=8);for(u=u<<o|a,c+=o;c>0;t[e+p]=255&u,p+=d,u/=256,c-=8);t[e+p-d]|=128*y}},{}],19:[function(n,e){(function(r){(function(){function o(t,n,e){var r=n&&e||0,o=0;for(n=n||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>o&&(n[r+o++]=g[t])});16>o;)n[r+o++]=0;return n}function i(t,n){var e=n||0,r=y;return r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]}function u(t,n,e){var r=n&&e||0,o=n||[];t=t||{};var u=null!=t.clockseq?t.clockseq:m,a=null!=t.msecs?t.msecs:(new Date).getTime(),s=null!=t.nsecs?t.nsecs:B+1,c=a-E+(s-B)/1e4;
if(0>c&&null==t.clockseq&&(u=u+1&16383),(0>c||a>E)&&null==t.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");E=a,B=s,m=u,a+=122192928e5;var f=(1e4*(268435455&a)+s)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var l=a/4294967296*1e4&268435455;o[r++]=l>>>8&255,o[r++]=255&l,o[r++]=l>>>24&15|16,o[r++]=l>>>16&255,o[r++]=u>>>8|128,o[r++]=255&u;for(var h=t.node||v,p=0;6>p;p++)o[r+p]=h[p];return n?n:i(o)}function a(t,n,e){var r=n&&e||0;"string"==typeof t&&(n="binary"==t?new d(16):null,t=null),t=t||{};var o=t.random||(t.rng||s)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n)for(var u=0;16>u;u++)n[r+u]=o[u];return n||i(o)}var s,c=this;if("function"==typeof n)try{var f=n("crypto").randomBytes;s=f&&function(){return f(16)}}catch(l){}if(!s&&c.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);s=function(){return crypto.getRandomValues(h),h}}if(!s){var p=new Array(16);s=function(){for(var t,n=0;16>n;n++)0===(3&n)&&(t=4294967296*Math.random()),p[n]=t>>>((3&n)<<3)&255;return p}}for(var d="function"==typeof r?r:Array,y=[],g={},b=0;256>b;b++)y[b]=(b+256).toString(16).substr(1),g[y[b]]=b;var w=s(),v=[1|w[0],w[1],w[2],w[3],w[4],w[5]],m=16383&(w[6]<<8|w[7]),E=0,B=0,I=a;if(I.v1=u,I.v4=a,I.parse=o,I.unparse=i,I.BufferClass=d,"function"==typeof t&&t.amd)t(function(){return I});else if("undefined"!=typeof e&&e.exports)e.exports=I;else{var A=c.uuid;I.noConflict=function(){return c.uuid=A,I},c.uuid=I}}).call(this)}).call(this,n("buffer").Buffer)},{buffer:16,crypto:11}],20:[function(n,e,r){!function(n,o){"use strict";"object"==typeof r&&e?e.exports=o():"function"==typeof t&&t.amd?t(o):n.PubSub=o()}("object"==typeof window&&window||this,function(){"use strict";function t(t){var n;for(n in t)if(t.hasOwnProperty(n))return!0;return!1}function n(t){return function(){throw t}}function e(t,e,r){try{t(e,r)}catch(o){setTimeout(n(o),0)}}function r(t,n,e){t(n,e)}function o(t,n,o,i){var u,a=c[n],s=i?r:e;if(c.hasOwnProperty(n))for(u in a)a.hasOwnProperty(u)&&s(a[u],t,o)}function i(t,n,e){return function(){var r=String(t),i=r.lastIndexOf(".");for(o(t,t,n,e);-1!==i;)r=r.substr(0,i),i=r.lastIndexOf("."),o(t,r,n)}}function u(n){for(var e=String(n),r=Boolean(c.hasOwnProperty(e)&&t(c[e])),o=e.lastIndexOf(".");!r&&-1!==o;)e=e.substr(0,o),o=e.lastIndexOf("."),r=Boolean(c.hasOwnProperty(e)&&t(c[e]));return r}function a(t,n,e,r){var o=i(t,n,r),a=u(t);return a?(e===!0?o():setTimeout(o,0),!0):!1}var s={},c={},f=-1;return s.publish=function(t,n){return a(t,n,!1,s.immediateExceptions)},s.publishSync=function(t,n){return a(t,n,!0,s.immediateExceptions)},s.subscribe=function(t,n){if("function"!=typeof n)return!1;c.hasOwnProperty(t)||(c[t]={});var e="uid_"+String(++f);return c[t][e]=n,e},s.unsubscribe=function(t){var n,e,r,o="string"==typeof t,i=!1;for(n in c)if(c.hasOwnProperty(n)){if(e=c[n],o&&e[t]){delete e[t],i=t;break}if(!o)for(r in e)e.hasOwnProperty(r)&&e[r]===t&&(delete e[r],i=!0)}return i},s})},{}]},{},[1])(1)});
//# sourceMappingURL=./babble.min.map

@@ -9,3 +9,3 @@ var babble = require('../index');

(function () {
var emma = babble.babbler('emma').subscribe();
var emma = babble.babbler('emma').connect();

@@ -71,3 +71,3 @@ function decideToPlay () {

(function () {
var jack = babble.babbler('jack').subscribe();
var jack = babble.babbler('jack').connect();

@@ -74,0 +74,0 @@ function decideToStart (response) {

var babble = require('../index');
var emma = babble.babbler('emma').subscribe(),
jack = babble.babbler('jack').subscribe();
var emma = babble.babbler('emma').connect(),
jack = babble.babbler('jack').connect();

@@ -6,0 +6,0 @@ function decideIfAvailable () {

var babble = require('../index'),
async = require('async');
// initialize pubnub
var pubnub = babble.pubsub.pubnub({
// initialize pubnub messaging
var pubnub = babble.messagers.pubnub({
publish_key: 'demo', // REPLACE THIS WITH YOUR PUBNUB PUBLISH KEY

@@ -13,3 +13,3 @@ subscribe_key: 'demo' // REPLACE THIS WITH YOUR PUBNUB SUBSCRIBE KEY

emma: function (cb) {
var emma = babble.babbler('emma').subscribe(pubnub, function () {
var emma = babble.babbler('emma').connect(pubnub, function () {
cb(null, emma);

@@ -20,3 +20,3 @@ });

jack: function (cb) {
var jack = babble.babbler('jack').subscribe(pubnub, function () {
var jack = babble.babbler('jack').connect(pubnub, function () {
cb(null, jack);

@@ -23,0 +23,0 @@ });

var babble = require('../index');
var emma = babble.babbler('emma').subscribe(),
jack = babble.babbler('jack').subscribe();
var emma = babble.babbler('emma').connect(),
jack = babble.babbler('jack').connect();

@@ -23,3 +23,4 @@ emma.listen('hi')

})
.listen(printMessage);
.listen()
.run(printMessage);

@@ -26,0 +27,0 @@ function printMessage (message, context) {

@@ -5,6 +5,13 @@ # babble history

## not yet released, version 0.5.0
## 2014-02-14, version 0.6.0
- Renamed functions `publish`, `subscribe`, `unsubscribe` to `send`, `connect`,
and `disconnect`. Renamed namespace `pubsub` to `messengers`.
## 2014-01-13, version 0.5.0
- Messages can now be of any type, not only string.
- Consistency of API improved.
- Improved examples.

@@ -11,0 +18,0 @@

@@ -96,3 +96,3 @@ var Babbler = require('./Babbler'),

// export pubsub interfaces
exports.pubsub = require('./pubsub');
// export messaging interfaces
exports.messagers = require('./messagers');
var uuid = require('node-uuid'),
pubsubInterfaces = require('./pubsub'),
messagers = require('./messagers'),

@@ -30,14 +30,14 @@ Block = require('./block/Block'),

/**
* Subscribe to a pubsub system
* @param {Object} [pubsub] A pubsub interface. Must have the following
* Connect to a messaging system
* @param {Object} [messager] A messaging interface. Must have the following
* functions:
* - subscribe(params: {id: string,
* - connect(params: {id: string,
* message: function, connect: function}) : function
* must return a function which, when invoked,
* unsubscribes again. parameter connect is optional.
* - publish(id: string, message: *)
* publish a message
* disconnects again. parameter connect is optional.
* - send(id: string, message: *)
* send a message
* A number of interfaces is provided under
* babble.pubsub. Default interface is
* babble.pubsub['default']
* babble.messagers. Default interface is
* babble.messagers['default']
* @param {Function} [callback] Called when subscription is completed. Called

@@ -47,25 +47,25 @@ * without parameters

*/
Babbler.prototype.subscribe = function subscribe (pubsub, callback) {
if (typeof pubsub === 'function') {
// function is called as subscribe(callback)
callback = pubsub;
pubsub = null;
Babbler.prototype.connect = function connect (messager, callback) {
if (typeof messager === 'function') {
// function is called as connect(callback)
callback = messager;
messager = null;
}
if (!pubsub) {
pubsub = pubsubInterfaces['default']();
if (!messager) {
messager = messagers['default']();
}
if (typeof pubsub.subscribe !== 'function') {
throw new Error('pubsub must contain a function ' +
'subscribe(params: {id: string, callback: function}) : function');
if (typeof messager.connect !== 'function') {
throw new Error('messager must contain a function ' +
'connect(params: {id: string, callback: function}) : function');
}
if (typeof pubsub.publish !== 'function') {
throw new Error('pubsub must contain a function ' +
'publish(params: {id: string, message: *})');
if (typeof messager.send !== 'function') {
throw new Error('messager must contain a function ' +
'send(params: {id: string, message: *})');
}
var me = this;
var unsubscribe = pubsub.subscribe({
var disconnect = messager.connect({
id: this.id,

@@ -106,9 +106,9 @@ message: function (envelope) {

if (typeof unsubscribe !== 'function') {
throw new Error('pubsub.subscribe must return a function to unsubscribe');
if (typeof disconnect !== 'function') {
throw new Error('messager.connect must return a function to disconnect');
}
// link functions to unsubscribe and publish
this.unsubscribe = unsubscribe;
this.publish = pubsub.publish;
// link functions to disconnect and send
this.disconnect = disconnect;
this.send = messager.send;

@@ -119,18 +119,18 @@ return this;

/**
* Unsubscribe from the pubsub system
* Disconnect from the babblebox
*/
Babbler.prototype.unsubscribe = function unsubscribe () {
// TODO: unsubscribe must also have a callback
// unsubscribe is overridden when running subscribe
throw new Error('Cannot unsubscribe: not subscribed');
Babbler.prototype.disconnect = function disconnect () {
// TODO: disconnect must also have a callback
// disconnect is overridden when running connect
throw new Error('Cannot disconnect: not connected');
};
/**
* Publish a message
* Send a message
* @param {String} id
* @param {*} message
*/
Babbler.prototype.publish = function publish (id, message) {
// publish is overridden when running subscribe
throw new Error('Cannot publish: not subscribed');
Babbler.prototype.send = function send (id, message) {
// send is overridden when running connect
throw new Error('Cannot send: not connected');
};

@@ -245,3 +245,3 @@

// send a response back to the other peer
this.publish(conversation.peer, {
this.send(conversation.peer, {
id: conversation.id,

@@ -248,0 +248,0 @@ from: this.id,

{
"name": "babble",
"version": "0.5.0",
"version": "0.6.0",
"description": "Dynamic communication flows between message based actors.",

@@ -5,0 +5,0 @@ "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",

@@ -13,4 +13,4 @@ # Babble

Babble uses pubsub to communicate between actors. It comes with built in
support to communicate locally, and has as support for
Babble uses customizable messaging to communicate between actors. It comes with
built in support to communicate locally, and has as support for
[pubnub](http://www.pubnub.com/) to connect actors distributed over multiple

@@ -57,4 +57,4 @@ devices.

var emma = babble.babbler('emma').subscribe(),
jack = babble.babbler('jack').subscribe();
var emma = babble.babbler('emma').connect(),
jack = babble.babbler('jack').connect();

@@ -64,7 +64,7 @@ emma.listen('ask age')

return 25;
}));
});
jack.ask('emma', 'ask age', function (age, context) {
console.log(context.from + ' is ' + age + ' years old');
}));
console.log(context.from + ' is ' + age + ' years old');
});
```

@@ -96,4 +96,4 @@

var emma = babble.babbler('emma').subscribe(),
jack = babble.babbler('jack').subscribe();
var emma = babble.babbler('emma').connect(),
jack = babble.babbler('jack').connect();

@@ -122,3 +122,4 @@ function printMessage (message, context) {

})
.listen(printMessage);
.listen()
.run(printMessage);
```

@@ -142,4 +143,4 @@

var emma = babble.babbler('emma').subscribe(),
jack = babble.babbler('jack').subscribe();
var emma = babble.babbler('emma').connect(),
jack = babble.babbler('jack').connect();

@@ -245,11 +246,11 @@ function decideIfAvailable () {

- `subscribe([pubsub: Object] [, callback])`
Subscribe to a pubsub system. Babble comes with interfaces to support various
pubsub systems: `pubnub`, `pubsub-js`, and `default`. These interfaces are
available in the `babble.pubsub` namespace. If parameter `pubsub` is not
provided, babble uses the `default` pubsub system, which works locally.
A pubsub system can be specified like:
- `connect([messager: Object] [, callback])`
Connect to a messaging system. Babble comes with interfaces to support various
messaging systems: `pubnub`, `pubsub-js`, and `default`. These interfaces are
available in the `babble.messagers` namespace. If parameter `messager` is not
provided, babble uses the `default` messaging system, which works locally.
A messaging system can be specified like:
```js
babbler.subscribe(babble.pubsub['pubnub'], function () {
babbler.connect(babble.messagers['pubnub'], function () {
// connected

@@ -259,6 +260,6 @@ });

- `unsubscribe()`
Unsubscribe from the subscribed pubsub system.
- `disconnect()`
Disconnect from the connected messaging system.
- `publish(id: String, message: *)`
- `send(id: String, message: *)`
Send a message to another peer.

@@ -328,1 +329,11 @@

npm test
# To do
- Implement mixin pattern, enrich any object (like an actor) with babbler functionality.
- Listen to patterns instead of a predefined message.
- Implement error handling
- Implement support for promises to allow async callback functions
- Store message history in the context.
- Implement conversations with multiple peers at the same time.

@@ -12,4 +12,4 @@ var assert = require('assert'),

beforeEach(function () {
emma = new Babbler('emma').subscribe();
jack = new Babbler('jack').subscribe();
emma = new Babbler('emma').connect();
jack = new Babbler('jack').connect();
});

@@ -22,4 +22,4 @@

emma.unsubscribe();
jack.unsubscribe();
emma.disconnect();
jack.disconnect();

@@ -31,5 +31,5 @@ emma = null;

it('should create and destroy a babbler', function() {
var susan = new Babbler('susan').subscribe();
var susan = new Babbler('susan').connect();
assert.ok(susan instanceof Babbler);
susan.unsubscribe();
susan.disconnect();
});

@@ -36,0 +36,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc