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

@ndn/ws-transport

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndn/ws-transport - npm Package Compare versions

Comparing version 0.0.20200909 to 0.0.20210203

6

lib/ws_node.js

@@ -1,7 +0,5 @@

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { __importDefault } = require("tslib");
const WsWebSocket = __importDefault(require("ws")).default;
import { __importDefault, __importStar } from "tslib";
import _cjsDefaultImport0 from "ws"; const WsWebSocket = __importDefault(_cjsDefaultImport0).default;
export function makeWebSocket(uri) {
return new WsWebSocket(uri, [], { perMessageDeflate: false });
}

@@ -0,5 +1,4 @@

import { __importDefault, __importStar } from "tslib";
import { L3Face, rxFromPacketIterable, Transport } from "@ndn/l3face";
import { EventIterator } from "event-iterator";
import PCancelable from "p-cancelable";
import pTimeout from "p-timeout";
import _cjsDefaultImport0 from "event-iterator"; const EventIterator = __importDefault(_cjsDefaultImport0).default;
import { makeWebSocket } from "./ws_browser.js";

@@ -64,16 +63,26 @@ /** WebSocket transport. */

function connect(uri, opts = {}) {
var _a;
return pTimeout(new PCancelable((resolve, reject, onCancel) => {
const { connectTimeout = 10000, signal, } = opts;
return new Promise((resolve, reject) => {
var _a;
const sock = makeWebSocket(uri);
const fail = (err) => {
sock.close();
reject(err);
};
const timeout = setTimeout(() => fail(new Error("connectTimeout")), connectTimeout);
const onabort = () => fail(new Error("abort"));
(_a = signal) === null || _a === void 0 ? void 0 : _a.addEventListener("abort", () => onabort);
const onerror = (evt) => {
sock.close();
reject(new Error(evt.message));
sock.close();
};
sock.addEventListener("error", onerror);
sock.addEventListener("open", () => {
var _a;
clearTimeout(timeout);
sock.removeEventListener("error", onerror);
(_a = signal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", onabort);
resolve(new WsTransport(sock, opts));
});
onCancel(() => sock.close());
}), (_a = opts.connectTimeout) !== null && _a !== void 0 ? _a : 10000);
});
}

@@ -80,0 +89,0 @@ WsTransport.connect = connect;

@@ -1,8 +0,4 @@

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { __importDefault } = require("tslib");
import { __importDefault, __importStar } from "tslib";
import { L3Face, rxFromPacketIterable, Transport } from "@ndn/l3face";
const { EventIterator } = require("event-iterator");
const PCancelable = __importDefault(require("p-cancelable")).default;
const pTimeout = __importDefault(require("p-timeout")).default;
import _cjsDefaultImport0 from "event-iterator"; const EventIterator = __importDefault(_cjsDefaultImport0).default;
import { makeWebSocket } from "./ws_node.js";

@@ -67,16 +63,26 @@ /** WebSocket transport. */

function connect(uri, opts = {}) {
var _a;
return pTimeout(new PCancelable((resolve, reject, onCancel) => {
const { connectTimeout = 10000, signal, } = opts;
return new Promise((resolve, reject) => {
var _a;
const sock = makeWebSocket(uri);
const fail = (err) => {
sock.close();
reject(err);
};
const timeout = setTimeout(() => fail(new Error("connectTimeout")), connectTimeout);
const onabort = () => fail(new Error("abort"));
(_a = signal) === null || _a === void 0 ? void 0 : _a.addEventListener("abort", () => onabort);
const onerror = (evt) => {
sock.close();
reject(new Error(evt.message));
sock.close();
};
sock.addEventListener("error", onerror);
sock.addEventListener("open", () => {
var _a;
clearTimeout(timeout);
sock.removeEventListener("error", onerror);
(_a = signal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", onabort);
resolve(new WsTransport(sock, opts));
});
onCancel(() => sock.close());
}), (_a = opts.connectTimeout) !== null && _a !== void 0 ? _a : 10000);
});
}

@@ -83,0 +89,0 @@ WsTransport.connect = connect;

import { L3Face, Transport } from "@ndn/l3face";
import type { AbortSignal } from "abort-controller";
/** WebSocket transport. */

@@ -19,2 +20,4 @@ export declare class WsTransport extends Transport {

connectTimeout?: number;
/** AbortSignal that allows canceling connection attempt via AbortController. */
signal?: AbortSignal | globalThis.AbortSignal;
/** Buffer amount (in bytes) to start TX throttling. */

@@ -21,0 +24,0 @@ highWaterMark?: number;

{
"name": "@ndn/ws-transport",
"version": "0.0.20200909",
"version": "0.0.20210203",
"description": "NDNts: WebSocket Transport",

@@ -25,10 +25,9 @@ "keywords": [

"dependencies": {
"@ndn/l3face": "0.0.20200909",
"@ndn/l3face": "0.0.20210203",
"abort-controller": "^3.0.0",
"event-iterator": "^2.0.0",
"p-cancelable": "^2.0.0",
"p-timeout": "^3.2.0",
"tslib": "^2.0.1",
"ws": "^7.3.1"
"tslib": "^2.1.0",
"ws": "^7.4.3"
},
"types": "lib/mod.d.ts"
}

@@ -33,3 +33,3 @@ # @ndn/ws-transport

// We can now send Interests and retrieve Data.
let seq = Math.floor(Math.random() * 99999999);
let seq = Math.floor(Math.random() * 1e9);
for (let i = 0; i < 5; ++i) {

@@ -41,3 +41,3 @@ try {

console.log(`>D ${data.name}`);
} catch (err) {
} catch (err: unknown) {
console.warn(err);

@@ -44,0 +44,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