vscode-jsonrpc
Advanced tools
Comparing version 0.10.0-pre.12 to 0.10.0-pre.13
@@ -8,1 +8,4 @@ export declare function defined(value: any): boolean; | ||
export declare function error(value: any): value is Error; | ||
export declare function func(value: any): value is Function; | ||
export declare function array<T>(value: any): value is T[]; | ||
export declare function stringArray(value: any): value is string[]; |
@@ -34,1 +34,13 @@ /*--------------------------------------------------------- | ||
exports.error = error; | ||
function func(value) { | ||
return toString.call(value) === '[object Function]'; | ||
} | ||
exports.func = func; | ||
function array(value) { | ||
return Array.isArray(value); | ||
} | ||
exports.array = array; | ||
function stringArray(value) { | ||
return array(value) && value.every(function (elem) { return string(elem); }); | ||
} | ||
exports.stringArray = stringArray; |
@@ -18,2 +18,3 @@ import { RequestType, ResponseError, ErrorCodes, NotificationType } from './messages'; | ||
onNotification<P>(type: NotificationType<P>, handler: INotificationHandler<P>): void; | ||
listen(): any; | ||
dispose(): void; | ||
@@ -20,0 +21,0 @@ } |
@@ -19,39 +19,2 @@ /*--------------------------------------------------------- | ||
var eventHandlers = Object.create(null); | ||
var connection = { | ||
sendNotification: function (type, params) { | ||
var notificatioMessage = { | ||
jsonrpc: version, | ||
method: type.method, | ||
params: params | ||
}; | ||
protocolWriter.write(notificatioMessage); | ||
}, | ||
onNotification: function (type, handler) { | ||
eventHandlers[type.method] = handler; | ||
}, | ||
dispose: function () { | ||
} | ||
}; | ||
if (client) { | ||
connection.sendRequest = function (type, params) { | ||
return new Promise(function (resolve, reject) { | ||
var id = sequenceNumber++; | ||
var requestMessage = { | ||
jsonrpc: version, | ||
id: id, | ||
method: type.method, | ||
params: params | ||
}; | ||
responseHandlers[String(id)] = { method: type.method, resolve: resolve, reject: reject }; | ||
protocolWriter.write(requestMessage); | ||
}); | ||
}; | ||
} | ||
else { | ||
connection.onRequest = function (type, handler) { | ||
requestHandlers[type.method] = handler; | ||
}; | ||
} | ||
inputStream.on('end', function () { return outputStream.end(); }); | ||
inputStream.on('close', function () { return outputStream.end(); }); | ||
function handleRequest(requestMessage) { | ||
@@ -193,3 +156,42 @@ function reply(resultOrError) { | ||
} | ||
new messageReader_1.MessageReader(inputStream, callback); | ||
var connection = { | ||
sendNotification: function (type, params) { | ||
var notificatioMessage = { | ||
jsonrpc: version, | ||
method: type.method, | ||
params: params | ||
}; | ||
protocolWriter.write(notificatioMessage); | ||
}, | ||
onNotification: function (type, handler) { | ||
eventHandlers[type.method] = handler; | ||
}, | ||
dispose: function () { | ||
}, | ||
listen: function () { | ||
new messageReader_1.MessageReader(inputStream, callback); | ||
} | ||
}; | ||
if (client) { | ||
connection.sendRequest = function (type, params) { | ||
return new Promise(function (resolve, reject) { | ||
var id = sequenceNumber++; | ||
var requestMessage = { | ||
jsonrpc: version, | ||
id: id, | ||
method: type.method, | ||
params: params | ||
}; | ||
responseHandlers[String(id)] = { method: type.method, resolve: resolve, reject: reject }; | ||
protocolWriter.write(requestMessage); | ||
}); | ||
}; | ||
} | ||
else { | ||
connection.onRequest = function (type, handler) { | ||
requestHandlers[type.method] = handler; | ||
}; | ||
} | ||
inputStream.on('end', function () { return outputStream.end(); }); | ||
inputStream.on('close', function () { return outputStream.end(); }); | ||
return connection; | ||
@@ -196,0 +198,0 @@ } |
{ | ||
"name": "vscode-jsonrpc", | ||
"description": "A json rpc implementation over streams", | ||
"version": "0.10.0-pre.12", | ||
"version": "0.10.0-pre.13", | ||
"author": "Visual Studio Code Team", | ||
@@ -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
26876
680