Merge pull request #538 from strongloop/fix/browser-bundle-size
Remove all usages of lodash
This commit is contained in:
commit
3ea2ac9f68
13
lib/jutil.js
13
lib/jutil.js
|
@ -1,5 +1,5 @@
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var _ = require('lodash');
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param newClass
|
* @param newClass
|
||||||
|
@ -77,7 +77,7 @@ function mixInto(sourceScope, targetScope, options) {
|
||||||
var shouldOverride = options.override || !targetPropertyExists || isDelegate;
|
var shouldOverride = options.override || !targetPropertyExists || isDelegate;
|
||||||
|
|
||||||
if (propertyName == '_mixins') {
|
if (propertyName == '_mixins') {
|
||||||
targetScope._mixins = _.union(targetScope._mixins, sourceScope._mixins);
|
mergeMixins(sourceScope._mixins, targetScope._mixins);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,3 +86,12 @@ function mixInto(sourceScope, targetScope, options) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mergeMixins(source, target) {
|
||||||
|
// hand-written equivalent of lodash.union()
|
||||||
|
for (var ix in source) {
|
||||||
|
var mx = source[ix];
|
||||||
|
if (target.indexOf(mx) === -1)
|
||||||
|
target.push(mx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ var util = require('util');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var i8n = require('inflection');
|
var i8n = require('inflection');
|
||||||
var _ = require('lodash');
|
|
||||||
var defineScope = require('./scope.js').defineScope;
|
var defineScope = require('./scope.js').defineScope;
|
||||||
var mergeQuery = utils.mergeQuery;
|
var mergeQuery = utils.mergeQuery;
|
||||||
var ModelBaseClass = require('./model.js');
|
var ModelBaseClass = require('./model.js');
|
||||||
|
@ -493,11 +492,16 @@ util.inherits(ReferencesMany, Relation);
|
||||||
* @returns {Array} The array of matching relation objects
|
* @returns {Array} The array of matching relation objects
|
||||||
*/
|
*/
|
||||||
function findBelongsTo(modelFrom, modelTo, keyTo) {
|
function findBelongsTo(modelFrom, modelTo, keyTo) {
|
||||||
return _.pluck(_.filter(modelFrom.relations, function (rel) {
|
return Object.keys(modelFrom.relations)
|
||||||
return (rel.type === RelationTypes.belongsTo &&
|
.map(function(k) { return modelFrom.relations[k]; })
|
||||||
rel.modelTo === modelTo &&
|
.filter(function(rel) {
|
||||||
(keyTo === undefined || rel.keyTo === keyTo));
|
return (rel.type === RelationTypes.belongsTo &&
|
||||||
}), 'keyFrom');
|
rel.modelTo === modelTo &&
|
||||||
|
(keyTo === undefined || rel.keyTo === keyTo));
|
||||||
|
})
|
||||||
|
.map(function(rel) {
|
||||||
|
return rel.keyFrom;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
"debug": "^2.1.1",
|
"debug": "^2.1.1",
|
||||||
"depd": "^1.0.0",
|
"depd": "^1.0.0",
|
||||||
"inflection": "^1.6.0",
|
"inflection": "^1.6.0",
|
||||||
"lodash": "~3.0.1",
|
|
||||||
"loopback-connector": "1.x",
|
"loopback-connector": "1.x",
|
||||||
"node-uuid": "^1.4.2",
|
"node-uuid": "^1.4.2",
|
||||||
"qs": "^2.3.3",
|
"qs": "^2.3.3",
|
||||||
|
|
Loading…
Reference in New Issue