# net-browserify

> A port of the net module for the browser.

Latest version **0.2.4** (published 2016-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install net-browserify
pnpm add net-browserify
yarn add net-browserify
bun add net-browserify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2016-09-04 |
| First published | 2014-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Emersion |
| Maintainers | emersion |
| Keywords | browserify, net, browser |

## Links

- npm: https://www.npmjs.com/package/net-browserify
- Repository: https://github.com/emersion/net-browserify
- Issues: https://github.com/emersion/net-browserify/issues
- npm.io page: https://npm.io/package/net-browserify

## Dependencies (3)

- [express](https://npm.io/package/express.md) ^4.10.6
- [express-ws](https://npm.io/package/express-ws.md) ^0.2.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.10.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.2.4 (latest) — 2016-09-04
- 0.2.3 — 2016-04-17
- 0.2.2 — 2015-09-22
- 0.2.1 — 2015-09-04
- 0.2.0 — 2015-08-07
- 0.1.7 — 2015-07-24
- 0.1.6 — 2014-12-23
- 0.1.5 — 2014-12-17
- 0.1.4 — 2014-08-27
- 0.1.3 — 2014-08-27

## README

net-browserify
==============

`net` module for browserify, with a websocket server proxy.

Supported methods:
* `net.connect(options, cb)`
* `net.isIP(input)`, `net.isIPv4(input)`, `net.isIPv6(input)`

Examples are available in `examples/`.

How to use
----------

### For the client

Just require this module or map this module to the `net` module with [Browserify](https://github.com/substack/node-browserify).
```
$ npm install net-browserify
```

You can set a custom proxy address if you want to:
```js
var net = require('net');

// Optionaly, set a custom proxy address
// (defaults to the current host & port)
net.setProxy({
	hostname: 'example.org',
	port: 42
});

// Use the net module like on a server
var socket = net.connect({
	host: 'google.com',
	port: 80
});

socket.on('connect', function () {
	console.log('Connected to google.com!');
});
```

### For the server

```js
var express = require('express');
var netApi = require('net-browserify');

// Create our app
var app = express();

app.use(netApi());

// Start the server
var server = app.listen(3000, function() {
	console.log('Server listening on port ' + server.address().port);
});
```

You can also specify some options:
```js
app.use(netApi({
	allowOrigin: '*', // Allow access from any origin
	to: [ // Restrict destination
		{ host: 'example.org', port: 42 }, // Restrict to example.org:42
		{ host: 'example.org' }, // Restrict to example.org, allow any port
		{ port: 42 }, // Restrict to port 42 only, allow any host
		{ host: 'bad.com', blacklist: true } // Blacklist bad.com
		// And so on...
	]
}));
```

License
-------

The MIT license.

---
_Source: https://npm.io/package/net-browserify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
