Replaced underscore with lodash
diff --git a/helpers/build.js b/helpers/build.js
index cb14ba2..afcf653 100644
--- a/helpers/build.js
+++ b/helpers/build.js
@@ -6,7 +6,7 @@
UsergridQuery = require('../lib/query'),
UsergridEntity = require('../lib/entity'),
ok = require('objectkit'),
- _ = require('underscore')
+ _ = require('lodash')
module.exports = {
url: function(options) {
@@ -40,7 +40,7 @@
}
if (typeof args[0] === 'object' && !(args[0] instanceof UsergridQuery)) {
- _.extend(options, args[0])
+ _.assign(options, args[0])
}
options.callback = helpers.cb(_.last(args.filter(_.isFunction)))
@@ -82,7 +82,7 @@
}
if (typeof args[0] === 'object' && !(args[0] instanceof UsergridEntity) && !(args[0] instanceof UsergridQuery)) {
- _.extend(options, args[0])
+ _.assign(options, args[0])
}
options.callback = helpers.cb(_.last(args.filter(_.isFunction)))
@@ -166,7 +166,7 @@
}
if (typeof args[0] === 'object' && !(args[0] instanceof UsergridQuery)) {
- _.extend(options, args[0])
+ _.assign(options, args[0])
}
options.callback = helpers.cb(_.last(args.filter(_.isFunction)))
diff --git a/helpers/cb.js b/helpers/cb.js
index 058648c..08206ef 100644
--- a/helpers/cb.js
+++ b/helpers/cb.js
@@ -1,3 +1,5 @@
+var _ = require('lodash')
+
module.exports = function(callback) {
- return (typeof callback === 'function') ? callback : function() {}
+ return _.isFunction(callback) ? callback : function() {}
}
\ No newline at end of file
diff --git a/helpers/config.js b/helpers/config.js
index 9fb5d8d..a35aa6b 100644
--- a/helpers/config.js
+++ b/helpers/config.js
@@ -1,7 +1,6 @@
'use strict'
var _ = require('lodash')
-_.mixin(require('underscore.string'))
if (/mocha$/i.test(process.argv[1])) {
var target = _(_.last(process.argv)).startsWith('--target=') ? _.last(process.argv).replace(/--target=/, '') : '1.0'
diff --git a/helpers/index.js b/helpers/index.js
index 4b08822..ac7d678 100644
--- a/helpers/index.js
+++ b/helpers/index.js
@@ -6,7 +6,7 @@
config = require('./config'),
_ = require('lodash')
-module.exports = _.extend(module.exports, {
+module.exports = _.assign(module.exports, {
cb: cb,
build: build,
userAgent: userAgent,
diff --git a/lib/appAuth.js b/lib/appAuth.js
index f7fe813..335c90e 100644
--- a/lib/appAuth.js
+++ b/lib/appAuth.js
@@ -2,7 +2,7 @@
var UsergridAuth = require('./auth'),
util = require('util'),
- _ = require('underscore')
+ _ = require('lodash')
var UsergridAppAuth = function() {
var self = this
@@ -15,7 +15,7 @@
self.clientSecret = args.clientSecret || args[1]
self.tokenTtl = args.tokenTtl || args[2]
UsergridAuth.call(self)
- _.extend(self, UsergridAuth)
+ _.assign(self, UsergridAuth)
return self
}
diff --git a/lib/client.js b/lib/client.js
index b50539e..3c37010 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -5,7 +5,7 @@
helpers = require('../helpers'),
config = helpers.config,
UsergridAppAuth = require('./appAuth'),
- _ = require('underscore')
+ _ = require('lodash')
var AuthFallback = {
APP: 'APP',
diff --git a/lib/entity.js b/lib/entity.js
index 84c838d..273f80a 100644
--- a/lib/entity.js
+++ b/lib/entity.js
@@ -2,7 +2,7 @@
var helpers = require('../helpers'),
ok = require('objectkit'),
- _ = require('underscore')
+ _ = require('lodash')
var UsergridEntity = function(obj) {
var self = this
@@ -11,7 +11,7 @@
throw new Error('A UsergridEntity object was initialized using an empty argument')
}
- _.extend(self, obj)
+ _.assign(self, obj)
if (typeof self.type !== 'string') {
throw new Error('"type" (or "collection") parameter is required when initializing a UsergridEntity object')
diff --git a/lib/query.js b/lib/query.js
index e661271..792290b 100644
--- a/lib/query.js
+++ b/lib/query.js
@@ -2,9 +2,7 @@
var helpers = require('../helpers'),
util = require('util'),
- _ = require('underscore')
-
-_.mixin(require('underscore.string'))
+ _ = require('lodash')
var UsergridQuery = function(type) {
@@ -16,7 +14,7 @@
__nextIsNot = false
// builder pattern
- _.extend(self, {
+ _.assign(self, {
type: function(value) {
self._type = value
return self
@@ -83,11 +81,11 @@
} else if (query.length === 0) {
return append
} else {
- return (_(query).endsWith('and') || _(query).endsWith('or')) ? util.format('%s %s', query, append) : util.format('%s and %s', query, append)
+ return (_.endsWith(query, 'and') || _.endsWith(query, 'or')) ? util.format('%s %s', query, append) : util.format('%s and %s', query, append)
}
},
orJoin: function() {
- return (query.length > 0 && !_(query).endsWith('or')) ? util.format('%s or', query) : query
+ return (query.length > 0 && !_.endsWith(query, 'or')) ? util.format('%s or', query) : query
}
})
diff --git a/lib/request.js b/lib/request.js
index f7b0cc1..edd0860 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -5,7 +5,7 @@
UsergridResponse = require('../lib/response'),
UsergridQuery = require('../lib/query'),
util = require('util'),
- _ = require('underscore')
+ _ = require('lodash')
var UsergridRequest = function(options) {
options.callback = helpers.cb(options.callback)
@@ -17,7 +17,7 @@
var headers = helpers.userAgent
if (options.client.appAuth && options.client.appAuth.isTokenValid) {
- _.extend(headers, {
+ _.assign(headers, {
authorization: util.format("Bearer %s", options.client.appAuth.token)
})
}
diff --git a/lib/response.js b/lib/response.js
index 181341e..26bf633 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -7,8 +7,6 @@
helpers = require('../helpers'),
_ = require('lodash')
-_.mixin(require('underscore.string'))
-
function UsergridResponse(response) {
if (!response) {
return
@@ -22,7 +20,7 @@
}
return entity
})
- _.extend(response, {
+ _.assign(response, {
metadata: _.cloneDeep(response.body),
entities: entities
})
diff --git a/lib/user.js b/lib/user.js
index 4deea07..0ddedbf 100644
--- a/lib/user.js
+++ b/lib/user.js
@@ -4,7 +4,7 @@
helpers = require('../helpers'),
ok = require('objectkit'),
util = require('util'),
- _ = require('underscore')
+ _ = require('lodash')
var UsergridUser = function(obj) {
@@ -14,7 +14,7 @@
}
var self = this
- _.extend(self, UsergridEntity.call(self, obj))
+ _.assign(self, UsergridEntity.call(self, obj))
helpers.setWritable(self, 'name')
return self
}
diff --git a/package.json b/package.json
index 38ebe86..76c2bf0 100644
--- a/package.json
+++ b/package.json
@@ -7,9 +7,6 @@
"lodash-uuid": "latest",
"objectkit": "latest",
"request": "latest",
- "underscore": "latest",
- "underscore.inflection": "latest",
- "underscore.string": "latest",
"url-join": "latest",
"volos-analytics-apigee": "latest",
"volos-analytics-common": "latest",
diff --git a/tests/lib/client.test.js b/tests/lib/client.test.js
index 17b0172..a093b46 100644
--- a/tests/lib/client.test.js
+++ b/tests/lib/client.test.js
@@ -6,7 +6,7 @@
UsergridEntity = require('../../lib/entity'),
UsergridQuery = require('../../lib/query'),
UsergridAppAuth = require('../../lib/appAuth'),
- _ = require('underscore')
+ _ = require('lodash')
_.mixin(require('lodash-uuid'))
@@ -291,7 +291,7 @@
this.slow(_slow)
this.timeout(_timeout)
- var updateEntity = _.extend(response.entity, {
+ var updateEntity = _.assign(response.entity, {
publisher: {
name: "George Newns",
date: "14 October 1892",
@@ -484,7 +484,7 @@
}
client.POST(options, function(err, usergridResponse) {
- client.DELETE(_.extend(options, {uuid: usergridResponse.entity.uuid}), function() {
+ client.DELETE(_.assign(options, {uuid: usergridResponse.entity.uuid}), function() {
client.GET(config.testCollection, usergridResponse.entity.uuid, function(err, delResponse) {
delResponse.error.name.should.equal((config.target === '1.0') ? 'service_resource_not_found' : 'entity_not_found')
done()
diff --git a/tests/lib/response.test.js b/tests/lib/response.test.js
index 5744592..e5f9fd1 100644
--- a/tests/lib/response.test.js
+++ b/tests/lib/response.test.js
@@ -6,7 +6,7 @@
UsergridEntity = require('../../lib/entity'),
UsergridUser = require('../../lib/user'),
UsergridResponseError = require('../../lib/responseError'),
- _ = require('underscore')
+ _ = require('lodash')
var client = new UsergridClient()
diff --git a/tests/lib/usergrid.test.js b/tests/lib/usergrid.test.js
index 59ce575..9da32af 100644
--- a/tests/lib/usergrid.test.js
+++ b/tests/lib/usergrid.test.js
@@ -5,7 +5,7 @@
Usergrid = require('../../usergrid'),
UsergridClient = require('../../lib/client'),
util = require('util'),
- _ = require('underscore')
+ _ = require('lodash')
describe('init() / initSharedInstance()', function() {
it('should be an instance of UsergridClient', function() {