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

simple-websocket

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-websocket - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

30

index.js

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

/* global Blob */
module.exports = Socket

@@ -5,3 +7,5 @@

var inherits = require('inherits')
var isTypedArray = require('is-typedarray')
var once = require('once')
var toBuffer = require('typedarray-to-buffer')
var ws = require('ws') // websockets in node - will be empty object in browser

@@ -29,6 +33,13 @@

Socket.prototype.send = function (message) {
if (this._ws && this._ws.readyState === WebSocket.OPEN) {
if (typeof message === 'object') message = JSON.stringify(message)
this._ws.send(message)
Socket.prototype.send = function (chunk) {
if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return
if (chunk instanceof ArrayBuffer || typeof chunk === 'string' ||
Buffer.isBuffer(chunk) || (typeof Blob !== 'undefined' && chunk instanceof Blob)) {
this._ws.send(chunk)
} else if (isTypedArray.strict(chunk)) {
// TODO: don't send full arraybuffer, respect the "view" on the arraybuffer
this._ws.send(chunk.buffer)
} else {
this._ws.send(JSON.stringify(chunk))
}

@@ -49,2 +60,3 @@ }

this._ws = new WebSocket(this._url)
this._ws.binaryType = 'arraybuffer'
this._ws.onopen = this._onopen.bind(this)

@@ -78,5 +90,9 @@ this._ws.onmessage = this._onmessage.bind(this)

var message = event.data
try {
message = JSON.parse(event.data)
} catch (err) {}
if (message instanceof ArrayBuffer) {
message = toBuffer(new Uint8Array(message))
} else {
try {
message = JSON.parse(message)
} catch (err) {}
}
this.emit('message', message)

@@ -83,0 +99,0 @@ }

{
"name": "simple-websocket",
"description": "Simple, EventEmitter API for WebSockets (browser)",
"version": "1.2.0",
"version": "1.3.0",
"author": {

@@ -18,3 +18,5 @@ "name": "Feross Aboukhadijeh",

"inherits": "^2.0.1",
"is-typedarray": "0.0.0",
"once": "^1.3.0",
"typedarray-to-buffer": "^3.0.1",
"ws": "^0.7.1"

@@ -21,0 +23,0 @@ },

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

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.SimpleWebsocket=e()}}(function(){return function e(t,n,r){function s(o,h){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!h&&u)return u(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(){},{}],2:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function s(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!s(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,s,h,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],o(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,h=new Array(s-1),u=1;s>u;u++)h[u-1]=arguments[u];n.apply(this,h)}else if(i(n)){for(s=arguments.length,h=new Array(s-1),u=1;s>u;u++)h[u-1]=arguments[u];for(c=n.slice(),s=c.length,u=0;s>u;u++)c[u].apply(this,h)}return!0},n.prototype.addListener=function(e,t){var s;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned){var s;s=o(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),s||(s=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var s=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,s,o,h;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,s=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(h=o;h-->0;)if(n[h]===t||n[h].listener&&n[h].listener===t){s=h;break}if(0>s)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],3:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],4:[function(e,t){function n(e,t){function r(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),s=t[t.length-1];return"function"==typeof r&&r!==s&&Object.keys(s).forEach(function(e){r[e]=s[e]}),r}if(e&&t)return n(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(t){r[t]=e[t]}),r}t.exports=n},{}],5:[function(e,t){function n(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}var r=e("wrappy");t.exports=r(n),n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0})})},{wrappy:4}],"/":[function(e,t){function n(e,t){return this instanceof n?(r.call(this),t||(t={}),this._url=e,this._reconnect=void 0!==t.reconnect?t.reconnect:h,this.ready=!1,void this._init()):new n(e,t)}t.exports=n;var r=e("events").EventEmitter,s=e("inherits"),i=e("once"),o=e("ws"),h=5e3,u="undefined"!=typeof window?window.WebSocket:o;s(n,r),n.prototype.send=function(e){this._ws&&this._ws.readyState===u.OPEN&&("object"==typeof e&&(e=JSON.stringify(e)),this._ws.send(e))},n.prototype.destroy=function(e){e&&this.once("close",e);try{this._ws.close()}catch(t){this._onclose()}},n.prototype._init=function(){this._errored=!1,this._ws=new u(this._url),this._ws.onopen=this._onopen.bind(this),this._ws.onmessage=this._onmessage.bind(this),this._ws.onclose=this._onclose.bind(this),this._ws.onerror=i(this._onerror.bind(this))},n.prototype._onopen=function(){this.ready=!0,this.emit("ready")},n.prototype._onerror=function(e){this._errored=!0,this.destroy(),this._reconnect?(this._timeout=setTimeout(this._init.bind(this),this._reconnect),this.emit("warning",e)):this.emit("error",e)},n.prototype._onmessage=function(e){var t=e.data;try{t=JSON.parse(e.data)}catch(n){}this.emit("message",t)},n.prototype._onclose=function(){clearTimeout(this._timeout),this._ws&&(this._ws.onopen=null,this._ws.onerror=null,this._ws.onmessage=null,this._ws.onclose=null),this._ws=null,this._errored||this.emit("close")}},{events:2,inherits:3,once:5,ws:1}]},{},[])("/")});
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.SimpleWebsocket=t()}}(function(){return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){var r=e[s][1][t];return i(r?r:t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(){},{}],2:[function(t,e,r){function n(t,e){var r=this;if(!(r instanceof n))return new n(t,e);var i,o=typeof t;if("number"===o)i=+t;else if("string"===o)i=n.byteLength(t,e);else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string");"Buffer"===t.type&&D(t.data)&&(t=t.data),i=+t.length}if(i>C)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C.toString(16)+" bytes");0>i?i=0:i>>>=0,n.TYPED_ARRAY_SUPPORT?r=n._augment(new Uint8Array(i)):(r.length=i,r._isBuffer=!0);var s;if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)r._set(t);else if(U(t))if(n.isBuffer(t))for(s=0;i>s;s++)r[s]=t.readUInt8(s);else for(s=0;i>s;s++)r[s]=(t[s]%256+256)%256;else if("string"===o)r.write(t,0,e);else if("number"===o&&!n.TYPED_ARRAY_SUPPORT)for(s=0;i>s;s++)r[s]=0;return i>0&&i<=n.poolSize&&(r.parent=k),r}function i(t,e){if(!(this instanceof i))return new i(t,e);var r=new n(t,e);return delete r.parent,r}function o(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function s(t,e,r,n){var i=x(R(e,t.length-r),t,r,n);return i}function a(t,e,r,n){var i=x(T(e),t,r,n);return i}function u(t,e,r,n){return a(t,e,r,n)}function h(t,e,r,n){var i=x(S(e),t,r,n);return i}function f(t,e,r,n){var i=x(P(e,t.length-r),t,r,n);return i}function c(t,e,r){return Y.fromByteArray(0===e&&r===t.length?t:t.slice(e,r))}function l(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=O(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+O(i)}function p(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function y(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function g(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=L(t[o]);return i}function w(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function d(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function v(t,e,r,i,o,s){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||s>e)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function E(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function _(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function b(t,e,r,n,i,o){if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function m(t,e,r,n,i){return i||b(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),M.write(t,e,r,n,23,4),r+4}function A(t,e,r,n,i){return i||b(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),M.write(t,e,r,n,52,8),r+8}function I(t){if(t=B(t).replace(N,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function B(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function U(t){return D(t)||n.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function L(t){return 16>t?"0"+t.toString(16):t.toString(16)}function R(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;n>s;s++){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((e-=3)>-1&&o.push(239,191,189),i=null);if(128>r){if((e-=1)<0)break;o.push(r)}else if(2048>r){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function T(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function P(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);s++)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function S(t){return Y.toByteArray(I(t))}function x(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function O(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var Y=t("base64-js"),M=t("ieee754"),D=t("is-array");r.Buffer=n,r.SlowBuffer=i,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var C=1073741823,k={};n.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),n.isBuffer=function(t){return!(null==t||!t._isBuffer)},n.compare=function(t,e){if(!n.isBuffer(t)||!n.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);s>o&&t[o]===e[o];o++);return o!==s&&(r=t[o],i=e[o]),i>r?-1:r>i?1:0},n.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}},n.concat=function(t,e){if(!D(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new n(0);if(1===t.length)return t[0];var r;if(void 0===e)for(e=0,r=0;r<t.length;r++)e+=t[r].length;var i=new n(e),o=0;for(r=0;r<t.length;r++){var s=t[r];s.copy(i,o),o+=s.length}return i},n.byteLength=function(t,e){var r;switch(t+="",e||"utf8"){case"ascii":case"binary":case"raw":r=t.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*t.length;break;case"hex":r=t.length>>>1;break;case"utf8":case"utf-8":r=R(t).length;break;case"base64":r=S(t).length;break;default:r=t.length}return r},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(t,e,r){var n=!1;if(e>>>=0,r=void 0===r||r===1/0?this.length:r>>>0,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return g(this,e,r);case"utf8":case"utf-8":return l(this,e,r);case"ascii":return p(this,e,r);case"binary":return y(this,e,r);case"base64":return c(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===n.compare(this,t)},n.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},n.prototype.compare=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:n.compare(this,t)},n.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i<t.length;i++)if(t[r+i]===e[-1===n?0:i-n]){if(-1===n&&(n=i),i-n+1===e.length)return r+n}else n=-1;return-1}if(e>2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(n.isBuffer(t))return r(this,t,e);if("number"==typeof t)return n.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},n.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},n.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},n.prototype.write=function(t,e,r,n){if(isFinite(e))isFinite(r)||(n=r,r=void 0);else{var i=n;n=e,e=r,r=i}if(e=Number(e)||0,0>r||0>e||e>this.length)throw new RangeError("attempt to write outside buffer bounds");var c=this.length-e;r?(r=Number(r),r>c&&(r=c)):r=c,n=String(n||"utf8").toLowerCase();var l;switch(n){case"hex":l=o(this,t,e,r);break;case"utf8":case"utf-8":l=s(this,t,e,r);break;case"ascii":l=a(this,t,e,r);break;case"binary":l=u(this,t,e,r);break;case"base64":l=h(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=f(this,t,e,r);break;default:throw new TypeError("Unknown encoding: "+n)}return l},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var i;if(n.TYPED_ARRAY_SUPPORT)i=n._augment(this.subarray(t,e));else{var o=e-t;i=new n(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},n.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},n.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},n.prototype.readUInt8=function(t,e){return e||d(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return e||d(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return e||d(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return e||d(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,e){return e||d(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},n.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},n.prototype.readInt8=function(t,e){return e||d(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){e||d(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(t,e){e||d(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(t,e){return e||d(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,e){return e||d(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,e){return e||d(t,4,this.length),M.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return e||d(t,4,this.length),M.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return e||d(t,8,this.length),M.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return e||d(t,8,this.length),M.read(this,t,!1,52,8)},n.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||v(this,t,e,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i>>>0&255;return e+r},n.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||v(this,t,e,r,Math.pow(2,8*r),0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o>>>0&255;return e+r},n.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,1,255,0),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},n.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):E(this,t,e,!0),e+2},n.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):E(this,t,e,!1),e+2},n.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):_(this,t,e,!0),e+4},n.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):_(this,t,e,!1),e+4},n.prototype.writeIntLE=function(t,e,r,n){t=+t,e>>>=0,n||v(this,t,e,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=0,o=1,s=0>t?1:0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=(t/o>>0)-s&255;return e+r},n.prototype.writeIntBE=function(t,e,r,n){t=+t,e>>>=0,n||v(this,t,e,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=r-1,o=1,s=0>t?1:0;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=(t/o>>0)-s&255;return e+r},n.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,1,127,-128),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},n.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):E(this,t,e,!0),e+2},n.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):E(this,t,e,!1),e+2},n.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):_(this,t,e,!0),e+4},n.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):_(this,t,e,!1),e+4},n.prototype.writeFloatLE=function(t,e,r){return m(this,t,e,!0,r)},n.prototype.writeFloatBE=function(t,e,r){return m(this,t,e,!1,r)},n.prototype.writeDoubleLE=function(t,e,r){return A(this,t,e,!0,r)},n.prototype.writeDoubleBE=function(t,e,r){return A(this,t,e,!1,r)},n.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var o=i-r;if(1e3>o||!n.TYPED_ARRAY_SUPPORT)for(var s=0;o>s;s++)t[s+e]=this[s+r];else t._set(this.subarray(r,r+o),e);return o},n.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=R(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var j=n.prototype;n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._set=t.set,t.get=j.get,t.set=j.set,t.write=j.write,t.toString=j.toString,t.toLocaleString=j.toString,t.toJSON=j.toJSON,t.equals=j.equals,t.compare=j.compare,t.indexOf=j.indexOf,t.copy=j.copy,t.slice=j.slice,t.readUIntLE=j.readUIntLE,t.readUIntBE=j.readUIntBE,t.readUInt8=j.readUInt8,t.readUInt16LE=j.readUInt16LE,t.readUInt16BE=j.readUInt16BE,t.readUInt32LE=j.readUInt32LE,t.readUInt32BE=j.readUInt32BE,t.readIntLE=j.readIntLE,t.readIntBE=j.readIntBE,t.readInt8=j.readInt8,t.readInt16LE=j.readInt16LE,t.readInt16BE=j.readInt16BE,t.readInt32LE=j.readInt32LE,t.readInt32BE=j.readInt32BE,t.readFloatLE=j.readFloatLE,t.readFloatBE=j.readFloatBE,t.readDoubleLE=j.readDoubleLE,t.readDoubleBE=j.readDoubleBE,t.writeUInt8=j.writeUInt8,t.writeUIntLE=j.writeUIntLE,t.writeUIntBE=j.writeUIntBE,t.writeUInt16LE=j.writeUInt16LE,t.writeUInt16BE=j.writeUInt16BE,t.writeUInt32LE=j.writeUInt32LE,t.writeUInt32BE=j.writeUInt32BE,t.writeIntLE=j.writeIntLE,t.writeIntBE=j.writeIntBE,t.writeInt8=j.writeInt8,t.writeInt16LE=j.writeInt16LE,t.writeInt16BE=j.writeInt16BE,t.writeInt32LE=j.writeInt32LE,t.writeInt32BE=j.writeInt32BE,t.writeFloatLE=j.writeFloatLE,t.writeFloatBE=j.writeFloatBE,t.writeDoubleLE=j.writeDoubleLE,t.writeDoubleBE=j.writeDoubleBE,t.fill=j.fill,t.inspect=j.inspect,t.toArrayBuffer=j.toArrayBuffer,t};var N=/[^+\/0-9A-z\-]/g},{"base64-js":3,ieee754:4,"is-array":5}],3:[function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===c?62:e===a||e===l?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:h+26>e?e-h+26:void 0}function r(t){function r(t){h[c++]=t}var n,i,s,a,u,h;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,h=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var c=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),h}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=r(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),h="a".charCodeAt(0),f="A".charCodeAt(0),c="-".charCodeAt(0),l="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],4:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,h=u>>1,f=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+c],c+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+c],c+=l,f-=8);if(0===o)o=1-h;else{if(o===u)return s?0/0:(p?-1:1)*(1/0);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<<h)-1,c=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+c>=1?l/u:l*Math.pow(2,1-c),e*u>=2&&(s++,u/=2),s+c>=f?(a=0,s=f):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=y,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;t[r+p]=255&s,p+=y,s/=256,h-=8);t[r+p-y]|=128*g}},{}],5:[function(t,e){var r=Array.isArray,n=Object.prototype.toString;e.exports=r||function(t){return!!t&&"[object Array]"==n.call(t)}},{}],6:[function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(h=r.slice(),i=h.length,u=0;i>u;u++)h[u].apply(this,a)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},{}],7:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],8:[function(t,e){function r(t){return n(t)||i(t)}function n(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function i(t){return s[o.call(t)]}e.exports=r,r.strict=n,r.loose=i;var o=Object.prototype.toString,s={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],9:[function(t,e){function r(t,e){function n(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var n=t.apply(this,e),i=e[e.length-1];return"function"==typeof n&&n!==i&&Object.keys(i).forEach(function(t){n[t]=i[t]}),n}if(t&&e)return r(t)(e);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(e){n[e]=t[e]}),n}e.exports=r},{}],10:[function(t,e){function r(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}var n=t("wrappy");e.exports=n(r),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0})})},{wrappy:9}],11:[function(t,e){(function(r){var n=t("is-typedarray").strict;e.exports=function(t){var e=r.TYPED_ARRAY_SUPPORT?r._augment:function(t){return new r(t)};return t instanceof Uint8Array?e(t):t instanceof ArrayBuffer?e(new Uint8Array(t)):n(t)?e(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)):new r(t)}}).call(this,t("buffer").Buffer)},{buffer:2,"is-typedarray":12}],12:[function(t,e,r){arguments[4][8][0].apply(r,arguments)},{dup:8}],"/":[function(t,e){(function(r){function n(t,e){return this instanceof n?(i.call(this),e||(e={}),this._url=t,this._reconnect=void 0!==e.reconnect?e.reconnect:f,this.ready=!1,void this._init()):new n(t,e)}e.exports=n;var i=t("events").EventEmitter,o=t("inherits"),s=t("is-typedarray"),a=t("once"),u=t("typedarray-to-buffer"),h=t("ws"),f=5e3,c="undefined"!=typeof window?window.WebSocket:h;o(n,i),n.prototype.send=function(t){this._ws&&this._ws.readyState===c.OPEN&&this._ws.send(t instanceof ArrayBuffer||"string"==typeof t||r.isBuffer(t)||"undefined"!=typeof Blob&&t instanceof Blob?t:s.strict(t)?t.buffer:JSON.stringify(t))},n.prototype.destroy=function(t){t&&this.once("close",t);try{this._ws.close()}catch(e){this._onclose()}},n.prototype._init=function(){this._errored=!1,this._ws=new c(this._url),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onopen.bind(this),this._ws.onmessage=this._onmessage.bind(this),this._ws.onclose=this._onclose.bind(this),this._ws.onerror=a(this._onerror.bind(this))},n.prototype._onopen=function(){this.ready=!0,this.emit("ready")},n.prototype._onerror=function(t){this._errored=!0,this.destroy(),this._reconnect?(this._timeout=setTimeout(this._init.bind(this),this._reconnect),this.emit("warning",t)):this.emit("error",t)},n.prototype._onmessage=function(t){var e=t.data;if(e instanceof ArrayBuffer)e=u(new Uint8Array(e));else try{e=JSON.parse(e)}catch(r){}this.emit("message",e)},n.prototype._onclose=function(){clearTimeout(this._timeout),this._ws&&(this._ws.onopen=null,this._ws.onerror=null,this._ws.onmessage=null,this._ws.onclose=null),this._ws=null,this._errored||this.emit("close")}}).call(this,t("buffer").Buffer)},{buffer:2,events:6,inherits:7,"is-typedarray":8,once:10,"typedarray-to-buffer":11,ws:1}]},{},[])("/")});
var Socket = require('../')
var test = require('tape')
test('basic echo test', function (t) {
var SOCKET_SERVER = 'wss://echo.websocket.org'
test('echo string', function (t) {
t.plan(3)
var socket = new Socket('wss://echo.websocket.org')
var socket = new Socket(SOCKET_SERVER)
socket.on('ready', function () {

@@ -13,2 +15,3 @@ t.pass('ready emitted')

t.equal(data, 'sup!')
socket.destroy(function () {

@@ -20,1 +23,55 @@ t.pass('destroyed socket')

})
test('echo Uint8Array', function (t) {
t.plan(4)
var socket = new Socket(SOCKET_SERVER)
socket.on('ready', function () {
t.pass('ready emitted')
socket.send(new Uint8Array([1, 2, 3]))
socket.on('message', function (data) {
t.ok(Buffer.isBuffer(data), 'data is Buffer')
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct message')
socket.destroy(function () {
t.pass('destroyed socket')
})
})
})
})
test('echo Buffer', function (t) {
t.plan(4)
var socket = new Socket(SOCKET_SERVER)
socket.on('ready', function () {
t.pass('ready emitted')
socket.send(new Buffer([1, 2, 3]))
socket.on('message', function (data) {
t.ok(Buffer.isBuffer(data), 'data is Buffer')
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct message')
socket.destroy(function () {
t.pass('destroyed socket')
})
})
})
})
test('echo ArrayBuffer', function (t) {
t.plan(4)
var socket = new Socket(SOCKET_SERVER)
socket.on('ready', function () {
t.pass('ready emitted')
socket.send(new Uint8Array([1, 2, 3]).buffer)
socket.on('message', function (data) {
t.ok(Buffer.isBuffer(data), 'data is Buffer')
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct message')
socket.destroy(function () {
t.pass('destroyed socket')
})
})
})
})

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