From ffa1d649b08222130705d673855d7442cfc6d465 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 19 Sep 2017 11:38:43 -0700 Subject: [PATCH] Add original name aliases for generated client methods --- packages/grpc-native-core/src/client.js | 3 +++ test/api/surface_test.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/packages/grpc-native-core/src/client.js b/packages/grpc-native-core/src/client.js index 0d8120d3..4208da11 100644 --- a/packages/grpc-native-core/src/client.js +++ b/packages/grpc-native-core/src/client.js @@ -912,6 +912,9 @@ exports.makeClientConstructor = function(methods, serviceName, } // Associate all provided attributes with the method _.assign(ServiceClient.prototype[name], attrs); + if (attrs.originalName) { + ServiceClient.prototype[attrs.originalName] = ServiceClient.prototype[name]; + } }); ServiceClient.service = methods; diff --git a/test/api/surface_test.js b/test/api/surface_test.js index 72a20fb9..b2072fdd 100644 --- a/test/api/surface_test.js +++ b/test/api/surface_test.js @@ -215,6 +215,10 @@ describe('Client constructor building', function() { grpc.makeGenericClientConstructor(illegal_service_attrs); }, /\$/); }); + it('Should add aliases for original names', function() { + var Client = grpc.makeGenericClientConstructor(mathServiceAttrs); + assert.strictEqual(Client.prototype.add, Client.prototype.Add); + }); }); describe('waitForClientReady', function() { var server;