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

booth

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

booth - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0

nanoevents.js

34

Booth.js

@@ -0,25 +1,28 @@

'use strict';
import Events from './Events'
import Endpoint from './Endpoint'
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var Events = _interopDefault(require('./Events'));
var Endpoint = _interopDefault(require('./Endpoint'));
var ws = require('ws');
export default function Booth (wss)
function Booth (wss)
{
wss = Wss(wss)
wss = Wss(wss);
var booth = { wss }
var booth = { wss };
var events = booth.events = Events(booth)
var events = booth.events = Events(booth);
booth.on = function on (...args)
{
events.on(...args)
events.on(...args);
return booth
}
};
booth.close = function close ()
{
wss.close()
}
wss.close();
};

@@ -29,4 +32,4 @@

{
Endpoint(ws, booth)
})
Endpoint(ws, booth);
});

@@ -37,5 +40,2 @@

import { Server } from 'ws'
function Wss (wss)

@@ -45,3 +45,3 @@ {

{
return new Server(wss)
return new ws.Server(wss)
}

@@ -56,1 +56,3 @@

}
module.exports = Booth;

@@ -0,10 +1,12 @@

'use strict';
import Events from './Events'
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var Events = _interopDefault(require('./Events'));
export default function Endpoint (ws, booth)
function Endpoint (ws, booth)
{
if (booth)
{
var events = booth.events
var events = booth.events;

@@ -16,7 +18,7 @@ var endp =

on () { return endp },
}
};
}
else
{
var events = Events()
var events = Events();

@@ -27,7 +29,7 @@ var endp =

on,
}
};
function on (...args)
{
events.on(...args)
events.on(...args);

@@ -43,18 +45,18 @@ return endp

{
endp.ws.close()
endp.ws.close();
}
endp.ws = Ws(ws)
endp.ws = Ws(ws);
ev('message', (data) => events.handle(data, endp))
ev('message', (data) => events.handle(data, endp));
ev('open', () => events.emit('@open', void 0, endp))
ev('close', () => events.emit('@close', void 0, endp))
ev('error', (e) => events.emit('@error', e, endp))
ev('open', () => events.emit('@open', void 0, endp));
ev('close', () => events.emit('@close', void 0, endp));
ev('error', (e) => events.emit('@error', e, endp));
ev('close', reconnect)
ev('close', reconnect);
if (booth)
{
setTimeout(() => events.emit('@open', void 0, endp))
setTimeout(() => events.emit('@open', void 0, endp));
}

@@ -64,3 +66,3 @@

{
endp.ws.addEventListener(name, handler)
endp.ws.addEventListener(name, handler);
}

@@ -75,5 +77,5 @@ }

endp.ws = null
endp.ws = null;
setTimeout(connect, 1e3)
setTimeout(connect, 1e3);
}

@@ -84,6 +86,6 @@

{
endp.ws.send('@' + kind + ':' + data)
endp.ws.send('@' + kind + ':' + data);
return endp
}
};

@@ -95,11 +97,11 @@ endp.close = function close ()

endp.ws.close()
endp.ws.close();
delete endp.ws
delete endp.booth
delete endp.ws;
delete endp.booth;
endp = null
}
endp = null;
};
connect()
connect();

@@ -110,4 +112,16 @@ return endp

import Client from 'isomorphic-ws'
// TODO: fix usage
// https://github.com/rollup/rollup-plugin-node-resolve/issues/177
// import Client from 'isomorphic-ws'
// var Client = window.WebSocket
if (typeof window !== 'undefined')
{
var Client = window.WebSocket;
}
else
{
var Client = require('isomorphic-ws');
}
function Ws (ws)

@@ -122,1 +136,3 @@ {

}
module.exports = Endpoint;

@@ -0,8 +1,10 @@

'use strict';
import Emitter from 'nanoevents'
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var Emitter = _interopDefault(require('./nanoevents'));
export default function Events ()
function Events ()
{
var emitter = new Emitter
var emitter = new Emitter;

@@ -14,3 +16,3 @@ var events =

handle,
}
};

@@ -21,7 +23,7 @@ function on (...args)

{
let map = args[0]
let map = args[0];
for (let key in map)
{
emitter.on(key, map[key])
emitter.on(key, map[key]);
}

@@ -31,3 +33,3 @@ }

{
emitter.on(args[0], args[1])
emitter.on(args[0], args[1]);
}

@@ -38,3 +40,3 @@ }

{
emitter.emit(...args)
emitter.emit(...args);
}

@@ -48,9 +50,9 @@

var colon = msg.indexOf(':')
var colon = msg.indexOf(':');
if (colon === -1) return
var kind = msg.slice(1, colon)
var data = msg.slice(colon + 1)
var kind = msg.slice(1, colon);
var data = msg.slice(colon + 1);
emitter.emit(kind, data, endp)
emitter.emit(kind, data, endp);
}

@@ -60,1 +62,3 @@

}
module.exports = Events;

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

'use strict';
export { default as Booth } from './Booth'
export { default as Endpoint } from './Endpoint'
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var Booth = _interopDefault(require('./Booth'));
var Endpoint = _interopDefault(require('./Endpoint'));
exports.Booth = Booth;
exports.Endpoint = Endpoint;
{
"name": "booth",
"version": "0.12.0",
"license": "ISC",
"author": "Strider <strange.transistor@gmail.com>",
"description": "Booth provides symmetric Event API over websocket or unix domain socket",
"homepage": "https://github.com/StreetStrider/booth",
"repository": { "url": "https://github.com/StreetStrider/booth.git", "type": "git" },
"bugs": { "url": "https://github.com/StreetStrider/booth/issues" },
"esm": true,
"engines": { "node": ">=8" },
"files":
[
"index.js",
"Events.js",
"Booth.js",
"Endpoint.js"
],
"peerDependencies":
{
"ws":
"6 || 7"
},
"scripts":
{
"start": "node -r esm readme",
"st": "eslint *.js test/",
"unit": "rm -f /tmp/booth; node -r esm test/unix.test",
"test": "npm run st && npm start && npm run unit"
},
"dependencies":
{
"isomorphic-ws":
"4",
"nanoevents":
"1",
"esm":
"3"
},
"devDependencies":
{
"eslint":
"5",
"js-outlander":
"StrangeTransistor/js-outlander#2.5.0",
"ws":
"6 || 7"
}
}
"name": "booth",
"version": "0.13.0",
"license": "ISC",
"author": "Strider <strange.transistor@gmail.com>",
"description": "Booth provides symmetric Event API over websocket or unix domain socket",
"homepage": "https://github.com/StreetStrider/booth",
"repository": {
"url": "https://github.com/StreetStrider/booth.git",
"type": "git"
},
"bugs": {
"url": "https://github.com/StreetStrider/booth/issues"
},
"engines": {
"node": ">=8"
},
"files": [
"index.js",
"Events.js",
"Booth.js",
"Endpoint.js",
"nanoevents.js"
],
"peerDependencies": {
"ws": "6 || 7"
},
"dependencies": {
"isomorphic-ws": "4"
}
}
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