vscode-jsonrpc
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -74,2 +74,5 @@ /* -------------------------------------------------------------------------------------------- | ||
} | ||
function isClosed() { | ||
return state === ConnectionState.Closed; | ||
} | ||
function isDisposed() { | ||
@@ -338,8 +341,18 @@ return state === ConnectionState.Disposed; | ||
}; | ||
var disposedMessage = 'Connection is disposed'; | ||
function throwIfClosedOrDisposed() { | ||
if (isClosed()) { | ||
throw new Error('Connection is closed.'); | ||
} | ||
if (isDisposed()) { | ||
throw new Error('Connection is disposed.'); | ||
} | ||
} | ||
function throwIfListening() { | ||
if (isListening()) { | ||
throw new Error('Connection is already listening'); | ||
} | ||
} | ||
var connection = { | ||
sendNotification: function (type, params) { | ||
if (isDisposed()) { | ||
throw new Error(disposedMessage); | ||
} | ||
throwIfClosedOrDisposed(); | ||
var notificatioMessage = { | ||
@@ -356,11 +369,7 @@ jsonrpc: version, | ||
onNotification: function (type, handler) { | ||
if (isDisposed()) { | ||
throw new Error(disposedMessage); | ||
} | ||
throwIfClosedOrDisposed(); | ||
eventHandlers[type.method] = handler; | ||
}, | ||
sendRequest: function (type, params, token) { | ||
if (isDisposed()) { | ||
throw new Error(disposedMessage); | ||
} | ||
throwIfClosedOrDisposed(); | ||
var id = sequenceNumber++; | ||
@@ -398,5 +407,3 @@ var result = new Promise(function (resolve, reject) { | ||
onRequest: function (type, handler) { | ||
if (isDisposed()) { | ||
throw new Error(disposedMessage); | ||
} | ||
throwIfClosedOrDisposed(); | ||
requestHandlers[type.method] = handler; | ||
@@ -431,8 +438,4 @@ }, | ||
listen: function () { | ||
if (isDisposed()) { | ||
throw new Error(disposedMessage); | ||
} | ||
if (isListening()) { | ||
throw new Error('Conneciton is already listening'); | ||
} | ||
throwIfClosedOrDisposed(); | ||
throwIfListening(); | ||
state = ConnectionState.Listening; | ||
@@ -439,0 +442,0 @@ messageReader.listen(callback); |
{ | ||
"name": "vscode-jsonrpc", | ||
"description": "A json rpc implementation over streams", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"author": "Microsoft Corporation", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
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
63559
1517