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

stream-url

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-url - npm Package Compare versions

Comparing version 0.0.10 to 0.0.12

2

package.json
{
"name": "stream-url",
"version": "0.0.10",
"version": "0.0.12",
"homepage": "http://github.com/gritzko/stream-url",

@@ -5,0 +5,0 @@ "repository": {

@@ -30,2 +30,5 @@ Stream URLs

technical details and make it easily pluggable.
Just replace `loopback://random_key` for `ws://myserver.com` or
`tcp://10.10.10.10:1234` and the component/micro-service now works in
a different setting.

@@ -35,7 +38,9 @@ ## API

* `listen(url [,options] [,callback])` start a server (stream factory)
listening at the `url`, using `options`. Invoke `callback` when
ready. The server will emit a `connection` event for every new
listening at the `url`, using `options`. Invoke `callback(err,
server)` when ready or failed.
The server will emit a `connection` event for every new
incoming connection/stream.
* `connect(url [,options] [,callback])` connect to a server at (create
a stream to) `url`. Invoke `callback` once ready to write.
a stream to) `url`. Invoke `callback(err, stream)` once ready to
write or failed to connect.
The stream will emit all the [usual events][stream]:

@@ -50,4 +55,20 @@ `data`, `end`, `error`.

All "real" protocols are defined in separate packages, as those
introduce non-trivial dependencies.
- [x] [server-side WebSocket][su-ws]
- [x] [TCP][su-node]
- [ ] [HTTP][su-node]
- [ ] [filesystem sockets][su-node]
- [ ] [stdin/stdout][su-node]
- [ ] [client-side WebSocket][su-bro]
- [ ] [postMessage][su-bro]
- [ ] [WebStorage][su-bro]
- [x] [loopback streams][swarm-bat]
[go]: https://gobyexample.com/channels
[stream]: https://iojs.org/api/stream.html
[test]: test/01_connect_listen.js
[su-ws]: https://github.com/gritzko/stream-url-ws
[su-node]: https://github.com/gritzko/stream-url-node
[su-bro]: https://github.com/gritzko/stream-url-browser
[swarm-bat]: https://github.com/gritzko/swarm

@@ -20,2 +20,15 @@ "use strict";

ZeroStream.prototype.drainQueue = function () {
try {
while (this.data.length && this.on_data) {
this.on_data(this.data.shift());
}
} catch (ex) {
console.error(ex.stack);
if (this.pair.on_error) {
this.pair.on_error(ex.message);
}
}
};
ZeroStream.prototype.on = function (event, callback) {

@@ -25,11 +38,4 @@ switch (event) {

this.on_data = callback;
try {
while (this.data.length) { // fake buffering
callback(this.data.shift());
}
} catch (ex) {
console.error(ex);
if (this.pair.on_error) {
this.pair.on_error(ex.message);
}
if (this.data.length) {
setTimeout(this.drain_queue.bind(this), 1);
}

@@ -51,3 +57,3 @@ break;

} catch (ex) {
console.error(ex);
console.error(ex.stack);
if (this.on_error) {

@@ -54,0 +60,0 @@ this.on_error(ex.message);

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