Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

usockets

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

usockets - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

28

browser.js

@@ -17,8 +17,8 @@

Socket.prototype.emitAsync = function emitAsync(event, payload) {
return new Promise((resolve, reject) => {
return this.emit(event, payload, (...args) => {
return new Promise(function(resolve, reject) {
return this.emit(event, payload, function(...args) {
if (args[0]) return reject(new Error(args[0]));
return resolve.apply(null, args);
});
});
}.bind(this));
};

@@ -31,3 +31,3 @@

const onDisconnect = () => {
const onDisconnect = function() {
clearTimeout(timeout);

@@ -37,4 +37,4 @@ reject(new Error('Socket disconnected'));

return new Promise((resolve, reject) => {
this.emit(options.event, { method, data }, (res) => {
return new Promise(function(resolve, reject) {
this.emit(options.event, { method, data }, function(res) {
clearTimeout(timeout);

@@ -46,9 +46,9 @@ this.removeListener('disconnect', onDisconnect);

resolve(res.data);
});
});
}.bind(this));
}.bind(this));
timeout = setTimeout(() => {
timeout = setTimeout(function() {
this.removeListener('disconnect', onDisconnect);
reject(new Error(`Socket request timeout: Exceeded ${options.timeout} msec`));
}, options.timeout);
}.bind(this), options.timeout);

@@ -62,12 +62,12 @@ this.once("disconnect", onDisconnect);

this.on(options.event, (req, ack) => {
this.on(options.event, function(req, ack) {
if (req.method !== method) return;
const res = (data) => {
const res = function(data) {
ack({ data });
};
res.error = (err) => {
res.error = function(err) {
ack({ error: JSON.stringify(err, replaceErrors)});
};
callback(req.data, res);
});
}.bind(this));
};

@@ -74,0 +74,0 @@

@@ -17,8 +17,8 @@

Socket.prototype.emitAsync = function emitAsync(event, payload) {
return new Promise((resolve, reject) => {
return this.emit(event, payload, (...args) => {
return new Promise(function (resolve, reject) {
return this.emit(event, payload, function (...args) {
if (args[0]) return reject(new Error(args[0]));
return resolve.apply(null, args);
});
});
}.bind(this));
};

@@ -31,3 +31,3 @@

const onDisconnect = () => {
const onDisconnect = function() {
clearTimeout(timeout);

@@ -37,4 +37,4 @@ reject(new Error('Socket disconnected'));

return new Promise((resolve, reject) => {
this.emit(options.event, { method, data }, (res) => {
return new Promise(function(resolve, reject) {
this.emit(options.event, { method, data }, function(res) {
clearTimeout(timeout);

@@ -46,9 +46,9 @@ this.removeListener('disconnect', onDisconnect);

resolve(res.data);
});
});
}.bind(this));
}.bind(this));
timeout = setTimeout(() => {
timeout = setTimeout(function() {
this.removeListener('disconnect', onDisconnect);
reject(new Error(`Socket request timeout: Exceeded ${options.timeout} msec`));
}, options.timeout);
}.bind(this), options.timeout);

@@ -62,12 +62,12 @@ this.once("disconnect", onDisconnect);

this.on(options.event, (req, ack) => {
this.on(options.event, function(req, ack) {
if (req.method !== method) return;
const res = (data) => {
const res = function(data) {
ack({ data });
};
res.error = (err) => {
res.error = function(err) {
ack({ error: JSON.stringify(err, replaceErrors)});
};
callback(req.data, res);
});
}.bind(this));
};

@@ -74,0 +74,0 @@

{
"name": "usockets",
"version": "0.0.3",
"version": "0.0.4",
"description": "Universal socket.io wrapper with promise and request/response support",

@@ -5,0 +5,0 @@ "license": "MIT",

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