From 55739d5c4a8ce7e8f66277d1f7639f8c2eb3bea2 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 3 Jun 2015 10:58:21 -0700 Subject: [PATCH] Replaced underscore and underscore.string modules with lodash --- src/node/cli/service_packager.js | 2 +- src/node/examples/perf_test.js | 2 +- src/node/examples/route_guide_client.js | 2 +- src/node/examples/route_guide_server.js | 2 +- src/node/examples/stock_server.js | 2 +- src/node/index.js | 2 +- src/node/interop/interop_client.js | 2 +- src/node/interop/interop_server.js | 2 +- src/node/package.json | 5 ++--- src/node/src/client.js | 2 +- src/node/src/common.js | 11 ++++------- src/node/src/server.js | 4 +--- src/node/test/surface_test.js | 6 ++---- 13 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/node/cli/service_packager.js b/src/node/cli/service_packager.js index f29180b2526..c92c450a01e 100644 --- a/src/node/cli/service_packager.js +++ b/src/node/cli/service_packager.js @@ -36,7 +36,7 @@ var fs = require('fs'); var path = require('path'); -var _ = require('underscore'); +var _ = require('lodash'); var async = require('async'); var pbjs = require('protobufjs/cli/pbjs'); var parseArgs = require('minimist'); diff --git a/src/node/examples/perf_test.js b/src/node/examples/perf_test.js index 31083e09872..da919eced53 100644 --- a/src/node/examples/perf_test.js +++ b/src/node/examples/perf_test.js @@ -35,7 +35,7 @@ var grpc = require('..'); var testProto = grpc.load(__dirname + '/../interop/test.proto').grpc.testing; -var _ = require('underscore'); +var _ = require('lodash'); var interop_server = require('../interop/interop_server.js'); function runTest(iterations, callback) { diff --git a/src/node/examples/route_guide_client.js b/src/node/examples/route_guide_client.js index 0b3e9c58192..8cd532fef17 100644 --- a/src/node/examples/route_guide_client.js +++ b/src/node/examples/route_guide_client.js @@ -37,7 +37,7 @@ var async = require('async'); var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); -var _ = require('underscore'); +var _ = require('lodash'); var grpc = require('..'); var examples = grpc.load(__dirname + '/route_guide.proto').examples; var client = new examples.RouteGuide('localhost:50051'); diff --git a/src/node/examples/route_guide_server.js b/src/node/examples/route_guide_server.js index 95553684220..c777eab7bcf 100644 --- a/src/node/examples/route_guide_server.js +++ b/src/node/examples/route_guide_server.js @@ -36,7 +36,7 @@ var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); -var _ = require('underscore'); +var _ = require('lodash'); var grpc = require('..'); var examples = grpc.load(__dirname + '/route_guide.proto').examples; diff --git a/src/node/examples/stock_server.js b/src/node/examples/stock_server.js index 8c22af147ed..caaf9f99bae 100644 --- a/src/node/examples/stock_server.js +++ b/src/node/examples/stock_server.js @@ -33,7 +33,7 @@ 'use strict'; -var _ = require('underscore'); +var _ = require('lodash'); var grpc = require('..'); var examples = grpc.load(__dirname + '/stock.proto').examples; diff --git a/src/node/index.js b/src/node/index.js index c09e416c6ed..b6a4e2d0ee5 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -33,7 +33,7 @@ 'use strict'; -var _ = require('underscore'); +var _ = require('lodash'); var ProtoBuf = require('protobufjs'); diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js index 455055d9f3c..b61b0b63c02 100644 --- a/src/node/interop/interop_client.js +++ b/src/node/interop/interop_client.js @@ -35,7 +35,7 @@ var fs = require('fs'); var path = require('path'); -var _ = require('underscore'); +var _ = require('lodash'); var grpc = require('..'); var testProto = grpc.load(__dirname + '/test.proto').grpc.testing; var GoogleAuth = require('google-auth-library'); diff --git a/src/node/interop/interop_server.js b/src/node/interop/interop_server.js index dad59c13477..0baa78a094f 100644 --- a/src/node/interop/interop_server.js +++ b/src/node/interop/interop_server.js @@ -35,7 +35,7 @@ var fs = require('fs'); var path = require('path'); -var _ = require('underscore'); +var _ = require('lodash'); var grpc = require('..'); var testProto = grpc.load(__dirname + '/test.proto').grpc.testing; var Server = grpc.buildServer([testProto.TestService.service]); diff --git a/src/node/package.json b/src/node/package.json index d7e9af07bdd..3ea2c065e70 100644 --- a/src/node/package.json +++ b/src/node/package.json @@ -25,10 +25,9 @@ }, "dependencies": { "bindings": "^1.2.0", + "lodash": "^3.9.3", "nan": "^1.5.0", - "protobufjs": "dcodeIO/ProtoBuf.js", - "underscore": "^1.6.0", - "underscore.string": "^3.0.0" + "protobufjs": "dcodeIO/ProtoBuf.js" }, "devDependencies": { "async": "^0.9.0", diff --git a/src/node/src/client.js b/src/node/src/client.js index 65339406b2c..b7bad949d45 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -33,7 +33,7 @@ 'use strict'; -var _ = require('underscore'); +var _ = require('lodash'); var grpc = require('bindings')('grpc.node'); diff --git a/src/node/src/common.js b/src/node/src/common.js index 98917c0fdd0..7b543353ebb 100644 --- a/src/node/src/common.js +++ b/src/node/src/common.js @@ -33,10 +33,7 @@ 'use strict'; -var _ = require('underscore'); - -var capitalize = require('underscore.string/capitalize'); -var decapitalize = require('underscore.string/decapitalize'); +var _ = require('lodash'); /** * Get a function that deserializes a specific type of protobuf. @@ -81,7 +78,7 @@ function fullyQualifiedName(value) { } var name = value.name; if (value.className === 'Service.RPCMethod') { - name = capitalize(name); + name = _.capitalize(name); } if (value.hasOwnProperty('parent')) { var parent_name = fullyQualifiedName(value.parent); @@ -118,8 +115,8 @@ function wrapIgnoreNull(func) { function getProtobufServiceAttrs(service) { var prefix = '/' + fullyQualifiedName(service) + '/'; return _.object(_.map(service.children, function(method) { - return [decapitalize(method.name), { - path: prefix + capitalize(method.name), + return [_.camelCase(method.name), { + path: prefix + _.capitalize(method.name), requestStream: method.requestStream, responseStream: method.responseStream, requestSerialize: serializeCls(method.resolvedRequestType.build()), diff --git a/src/node/src/server.js b/src/node/src/server.js index 079495afd4c..c6cf9e7eb80 100644 --- a/src/node/src/server.js +++ b/src/node/src/server.js @@ -33,7 +33,7 @@ 'use strict'; -var _ = require('underscore'); +var _ = require('lodash'); var grpc = require('bindings')('grpc.node'); @@ -48,8 +48,6 @@ var util = require('util'); var EventEmitter = require('events').EventEmitter; -var common = require('./common.js'); - /** * Handle an error on a call by sending it as a status * @param {grpc.Call} call The call to send the error on diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js index b390f8b2a55..8d1f99aaee0 100644 --- a/src/node/test/surface_test.js +++ b/src/node/test/surface_test.js @@ -45,9 +45,7 @@ var math_proto = ProtoBuf.loadProtoFile(__dirname + '/../examples/math.proto'); var mathService = math_proto.lookup('math.Math'); -var capitalize = require('underscore.string/capitalize'); - -var _ = require('underscore'); +var _ = require('lodash'); describe('File loader', function() { it('Should load a proto file by default', function() { @@ -159,7 +157,7 @@ describe('Generic client and server', function() { server = new Server({ string: { capitalize: function(call, callback) { - callback(null, capitalize(call.request)); + callback(null, _.capitalize(call.request)); } } });