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

stubborn-ws

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stubborn-ws - npm Package Compare versions

Comparing version 0.1.3 to 1.0.0

src/utils.js

2

package.json
{
"name": "stubborn-ws",
"version": "0.1.3",
"version": "1.0.0",
"description": "",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/ybonnefond/stubborn#stubborn",

@@ -22,3 +22,3 @@ # Stubborn

```bash
npm install --save-dev stubborn
npm install --save-dev stubborn-ws
```

@@ -28,3 +28,3 @@

```bash
yarn add -D stubborn
yarn add -D stubborn-ws
```

@@ -31,0 +31,0 @@

@@ -10,3 +10,3 @@ 'use strict';

const sb = new Stubborn({ port: 0 });
const sb = new Stubborn();

@@ -13,0 +13,0 @@ expect.extend({

@@ -7,2 +7,3 @@ 'use strict';

const middlewares = require('./middlewares');
const { getServerPort } = require('./utils');

@@ -12,7 +13,6 @@ class Router {

this.options = Object.assign({
host: '',
port: 0
host: ''
}, options);
this.port = this.options.port;
this.port = null;
this.routes = new Set();

@@ -51,9 +51,4 @@

setPort(port) {
this.port = port;
return this;
}
handle(server) {
this.port = getServerPort(server);
const mws = buildMiddlewares(this);

@@ -60,0 +55,0 @@ mws.push(buildRequestHandler(this));

@@ -6,2 +6,3 @@ 'use strict';

const { METHODS } = require('./constants');
const { getServerPort } = require('./utils');

@@ -19,3 +20,2 @@ class Stubborn {

this.options = Object.assign({
port: 8080,
host: 'localhost',

@@ -25,5 +25,5 @@ defaultHeaders: {}

this.port = null;
this.server = http.createServer();
this.router = new Router({ host: this.options.host, port: this.options.port });
this.router.handle(this.server);
this.router = new Router({ host: this.options.host });
}

@@ -39,11 +39,3 @@

getPort() {
if (0 === this.options.port) {
const address = this.server.address();
if (null !== address) {
return address.port;
}
}
return this.options.port;
return getServerPort(this.server);
}

@@ -138,6 +130,7 @@

*/
start() {
start(port = 0) {
this.port = port;
return new Promise((resolve) => {
this.server.listen(this.options.port);
this.router.setPort(this.getPort());
this.server.listen(this.port);
this.router.handle(this.server);
resolve();

@@ -144,0 +137,0 @@ });

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