rpcinterface
Advanced tools
+3
-0
| ## Changelog ## | ||
| ### 0.1.0 ### | ||
| * Exceptions throw in handler will now correctly throw if using promise in preProcessor | ||
| ### 0.0.11 ### | ||
@@ -4,0 +7,0 @@ * `array` type is now enforced (`object` still continue to match arrays and objects) |
+1
-1
| { | ||
| "name": "rpcinterface", | ||
| "version": "0.0.11", | ||
| "version": "0.1.0", | ||
| "description": "Library that facilitates an RPC interface in a webapp or node app", | ||
@@ -5,0 +5,0 @@ "main": "node-index.js", |
+1
-1
@@ -42,3 +42,3 @@ # rpcinterface # | ||
| ### rpc.call(method, params) ### | ||
| ### rpc.call(method[, params]) ### | ||
@@ -45,0 +45,0 @@ Calls a method added by `addMethod` and sends along the passed params. Returns a |
+2
-2
@@ -113,4 +113,4 @@ var _EMPTY_OBJECT_ = {}, | ||
| preDfd = this.preProcessor(method, parameters, dfd); | ||
| if (preDfd && typeof preDfd.then === 'function') { | ||
| preDfd.then(function() { | ||
| if (preDfd && typeof preDfd.done === 'function') { | ||
| preDfd[typeof dfd.done === 'function' ? 'done' : 'then'](function() { | ||
| if (deferredPending(dfd)) { | ||
@@ -117,0 +117,0 @@ return; |
+34
-0
@@ -250,1 +250,35 @@ var Deferred = require('deferred'), | ||
| }; | ||
| exports.callTestResolveNull = function(test) { | ||
| test.expect(1); | ||
| var rpc = new RPCInterface(); | ||
| rpc.addMethod('test', { | ||
| handler: function(params, dfd) { | ||
| dfd.resolve(null); | ||
| }, | ||
| params: { | ||
| test: {type: 'array', optional: false} | ||
| } | ||
| }); | ||
| rpc.call('test', {test: []}).then(function(result) { | ||
| test.strictEqual(result, null); | ||
| test.done(); | ||
| }); | ||
| }; | ||
| exports.callTestResolveUndefined = function(test) { | ||
| test.expect(1); | ||
| var rpc = new RPCInterface(); | ||
| rpc.addMethod('test', { | ||
| handler: function(params, dfd) { | ||
| dfd.resolve(); | ||
| }, | ||
| params: { | ||
| test: {type: 'array', optional: false} | ||
| } | ||
| }); | ||
| rpc.call('test', {test: []}).then(function(result) { | ||
| test.strictEqual(result, undefined); | ||
| test.done(); | ||
| }); | ||
| }; |
16405
6.59%424
8.16%