rxjs-websockets
Advanced tools
Comparing version 7.0.1 to 7.0.2
@@ -15,3 +15,5 @@ import { Observable, Subject } from 'rxjs'; | ||
setClosedStatus(); | ||
observer.error(new Error('Web socket message factory function called more than once')); | ||
const error = new Error('Web socket message factory function called more than once'); | ||
observer.error(error); | ||
throw error; | ||
} | ||
@@ -18,0 +20,0 @@ else { |
@@ -27,2 +27,6 @@ import 'mocha'; | ||
constructor() { | ||
this.onmessage = (event) => { }; | ||
this.onopen = (event) => { }; | ||
this.onclose = (event) => { }; | ||
this.onerror = (event) => { }; | ||
this.close = sinon.stub(); | ||
@@ -33,3 +37,3 @@ } | ||
} | ||
const connectHelper = (mockSocket, protocols) => connect('url', { protocols, makeWebSocket: () => mockSocket }); | ||
const connectHelper = (mockSocket, protocols = []) => connect('url', { protocols, makeWebSocket: () => mockSocket }); | ||
it('connects to websocket lazily and retrieves data', () => { | ||
@@ -53,3 +57,3 @@ const mockSocket = new MockSocket(); | ||
if (mockSocket.onopen) | ||
mockSocket.onopen(); | ||
mockSocket.onopen({}); | ||
}, 20); | ||
@@ -61,3 +65,3 @@ flush(); | ||
const socket = connectHelper(mockSocket); | ||
scheduler.schedule(() => mockSocket.onopen(), 10); | ||
scheduler.schedule(() => mockSocket.onopen({}), 10); | ||
expect$(socket.pipe(switchMap(factory => factory(cold('a|')))), '--!').toBe('-a'); | ||
@@ -71,3 +75,3 @@ flush(); | ||
const socket = connectHelper(mockSocket); | ||
scheduler.schedule(() => mockSocket.onopen(), 10); | ||
scheduler.schedule(() => mockSocket.onopen({}), 10); | ||
scheduler.schedule(() => mockSocket.onclose({ reason, code }), 30); | ||
@@ -74,0 +78,0 @@ expect$(socket.pipe(switchMap(factory => factory(cold('a'))), |
@@ -18,3 +18,5 @@ "use strict"; | ||
setClosedStatus(); | ||
observer.error(new Error('Web socket message factory function called more than once')); | ||
var error = new Error('Web socket message factory function called more than once'); | ||
observer.error(error); | ||
throw error; | ||
} | ||
@@ -21,0 +23,0 @@ else { |
@@ -29,2 +29,6 @@ "use strict"; | ||
function MockSocket() { | ||
this.onmessage = function (event) { }; | ||
this.onopen = function (event) { }; | ||
this.onclose = function (event) { }; | ||
this.onerror = function (event) { }; | ||
this.close = sinon.stub(); | ||
@@ -37,2 +41,3 @@ } | ||
var connectHelper = function (mockSocket, protocols) { | ||
if (protocols === void 0) { protocols = []; } | ||
return _1.default('url', { protocols: protocols, makeWebSocket: function () { return mockSocket; } }); | ||
@@ -58,3 +63,3 @@ }; | ||
if (mockSocket.onopen) | ||
mockSocket.onopen(); | ||
mockSocket.onopen({}); | ||
}, 20); | ||
@@ -66,3 +71,3 @@ flush(); | ||
var socket = connectHelper(mockSocket); | ||
scheduler.schedule(function () { return mockSocket.onopen(); }, 10); | ||
scheduler.schedule(function () { return mockSocket.onopen({}); }, 10); | ||
expect$(socket.pipe(operators_1.switchMap(function (factory) { return factory(cold('a|')); })), '--!').toBe('-a'); | ||
@@ -76,3 +81,3 @@ flush(); | ||
var socket = connectHelper(mockSocket); | ||
scheduler.schedule(function () { return mockSocket.onopen(); }, 10); | ||
scheduler.schedule(function () { return mockSocket.onopen({}); }, 10); | ||
scheduler.schedule(function () { return mockSocket.onclose({ reason: reason, code: code }); }, 30); | ||
@@ -79,0 +84,0 @@ expect$(socket.pipe(operators_1.switchMap(function (factory) { return factory(cold('a')); }), |
@@ -16,3 +16,5 @@ import { Observable, Subject } from 'rxjs'; | ||
setClosedStatus(); | ||
observer.error(new Error('Web socket message factory function called more than once')); | ||
var error = new Error('Web socket message factory function called more than once'); | ||
observer.error(error); | ||
throw error; | ||
} | ||
@@ -19,0 +21,0 @@ else { |
@@ -27,2 +27,6 @@ import 'mocha'; | ||
function MockSocket() { | ||
this.onmessage = function (event) { }; | ||
this.onopen = function (event) { }; | ||
this.onclose = function (event) { }; | ||
this.onerror = function (event) { }; | ||
this.close = sinon.stub(); | ||
@@ -35,2 +39,3 @@ } | ||
var connectHelper = function (mockSocket, protocols) { | ||
if (protocols === void 0) { protocols = []; } | ||
return connect('url', { protocols: protocols, makeWebSocket: function () { return mockSocket; } }); | ||
@@ -56,3 +61,3 @@ }; | ||
if (mockSocket.onopen) | ||
mockSocket.onopen(); | ||
mockSocket.onopen({}); | ||
}, 20); | ||
@@ -64,3 +69,3 @@ flush(); | ||
var socket = connectHelper(mockSocket); | ||
scheduler.schedule(function () { return mockSocket.onopen(); }, 10); | ||
scheduler.schedule(function () { return mockSocket.onopen({}); }, 10); | ||
expect$(socket.pipe(switchMap(function (factory) { return factory(cold('a|')); })), '--!').toBe('-a'); | ||
@@ -74,3 +79,3 @@ flush(); | ||
var socket = connectHelper(mockSocket); | ||
scheduler.schedule(function () { return mockSocket.onopen(); }, 10); | ||
scheduler.schedule(function () { return mockSocket.onopen({}); }, 10); | ||
scheduler.schedule(function () { return mockSocket.onclose({ reason: reason, code: code }); }, 30); | ||
@@ -77,0 +82,0 @@ expect$(socket.pipe(switchMap(function (factory) { return factory(cold('a')); }), |
{ | ||
"name": "rxjs-websockets", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"description": "rxjs 6 websockets library", | ||
@@ -8,3 +8,3 @@ "main": "lib.es5/index.js", | ||
"es2015": "lib.es2015/index.js", | ||
"typings": "lib/index", | ||
"typings": "lib.es2015/index", | ||
"repository": { | ||
@@ -26,6 +26,7 @@ "type": "git", | ||
"prepublish": "yarn build", | ||
"build": "tsc -p src/tsconfig.json && tsc -p src/tsconfig.es5.json && tsc -p src/tsconfig.es5.json -m es2015 --outDir lib.es5m", | ||
"build": "tsc -p src/tsconfig.json && npm run build:es5 && npm run build:es5 -- -m es2015 --outDir lib.es5m", | ||
"build:es5": "tsc -p src/tsconfig.es5.json", | ||
"build:watch": "tsc -w --preserveWatchOutput -p src/tsconfig.es5.json", | ||
"test": "npm run build && npm run mocha", | ||
"watch": "npm run build && concurrently 'npm run build:watch' 'npm run mocha:watch'", | ||
"watch": "npm run build:es5 && concurrently 'npm run build:watch' 'npm run mocha:watch'", | ||
"prepare": "npm run build", | ||
@@ -51,4 +52,4 @@ "mocha": "mocha lib.es5/*.spec.js", | ||
"sinon-chai": "3.3.0", | ||
"typescript": "3.5.2" | ||
"typescript": "3.5.3" | ||
} | ||
} |
@@ -10,3 +10,3 @@ import 'mocha' | ||
import connect, { normalClosureMessage } from '.' | ||
import connect, { normalClosureMessage, IWebSocket } from '.' | ||
@@ -31,5 +31,6 @@ chai.use(sinonChai) | ||
class MockSocket { | ||
onmessage: Function | ||
onopen: Function | ||
onclose: Function | ||
onmessage = (event: any) => {} | ||
onopen = (event: any) => {} | ||
onclose = (event: any) => {} | ||
onerror = (event: any) => {} | ||
close = sinon.stub() | ||
@@ -40,3 +41,3 @@ // forwards input as output | ||
const connectHelper = (mockSocket, protocols?: string | string[]) => | ||
const connectHelper = (mockSocket: IWebSocket, protocols: string | string[] = []) => | ||
connect('url', { protocols, makeWebSocket: () => mockSocket }) | ||
@@ -69,3 +70,3 @@ | ||
if (mockSocket.onopen) | ||
mockSocket.onopen() | ||
mockSocket.onopen({}) | ||
}, 20) | ||
@@ -79,3 +80,3 @@ | ||
const socket = connectHelper(mockSocket) | ||
scheduler.schedule(() => mockSocket.onopen(), 10) | ||
scheduler.schedule(() => mockSocket.onopen({}), 10) | ||
@@ -95,3 +96,3 @@ expect$( | ||
const socket = connectHelper(mockSocket) | ||
scheduler.schedule(() => mockSocket.onopen(), 10) | ||
scheduler.schedule(() => mockSocket.onopen({}), 10) | ||
scheduler.schedule(() => mockSocket.onclose({ reason, code }), 30) | ||
@@ -98,0 +99,0 @@ expect$( |
@@ -33,3 +33,3 @@ import { Observable, Subscription, Subject } from 'rxjs' | ||
const defaultProtocols = [] | ||
const defaultProtocols: string[] = [] | ||
@@ -66,3 +66,5 @@ const defaultWebsocketFactory: WebSocketFactory = ( | ||
setClosedStatus() | ||
observer.error(new Error('Web socket message factory function called more than once')) | ||
const error = new Error('Web socket message factory function called more than once') | ||
observer.error(error) | ||
throw error | ||
} else { | ||
@@ -69,0 +71,0 @@ inputSubscription = input.subscribe(data => { socket.send(data) }) |
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"strict": true, | ||
"lib": ["es6", "dom"], | ||
@@ -5,0 +6,0 @@ "moduleResolution": "node", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
58690
757
0