1
0
Fork 0

Avoid _.clone

Lodash's clone is subtlely different from underscore's and breaks with ShapedJson.
This commit is contained in:
Alan Plum 2015-12-22 15:53:02 +01:00
parent de9ae5128a
commit 9ecc710491
6 changed files with 8 additions and 8 deletions

View File

@ -94,7 +94,7 @@ exports.Foxxes = function () {
result.forEach(function(r, i) {
// inject development flag
if (r._key.match(/^dev:/)) {
result[i] = _.clone(r);
result[i] = _.extend({}, r);
result[i].development = true;
}
});

View File

@ -52,7 +52,7 @@ var stringToArray = function (x) {
if (typeof x === "string") {
return [x];
}
return _.clone(x);
return x.slice();
};
////////////////////////////////////////////////////////////////////////////////
@ -964,7 +964,7 @@ AQLGenerator.prototype.neighbors = function(vertexExample, options) {
+ this.stack.length + ')';
var opts;
if (options) {
opts = _.clone(options);
opts = _.extend({}, options);
} else {
opts = {};
}
@ -2471,7 +2471,7 @@ var _renameCollection = function(oldName, newName) {
return;
}
gdb.toArray().forEach(function(doc) {
var c = _.clone(doc), i, j, changed = false;
var c = _.extend({}, doc), i, j, changed = false;
if (c.edgeDefinitions) {
for (i = 0; i < c.edgeDefinitions.length; ++i) {
var def = c.edgeDefinitions[i];

View File

@ -1106,7 +1106,7 @@ function buildRouting (dbname) {
while (i.hasNext()) {
var n = i.next();
var c = _.clone(n);
var c = _.extend({}, n);
c.name = '_routing.document("' + c._key + '")';

View File

@ -787,7 +787,7 @@ exports.Communication = function() {
diff.missing.push(toAdd);
return;
}
var compTo = _.clone(inferior[k]);
var compTo = _.extend({}, inferior[k]);
delete compTo.address;
if (JSON.stringify(v) !== JSON.stringify(compTo)) {
diff.difference[k] = {};

View File

@ -267,7 +267,7 @@ function refillCaches(dbname) {
while (cursor.hasNext()) {
var config = cursor.next();
var app = new FoxxService(_.clone(config));
var app = new FoxxService(_.extend({}, config));
var mount = app.mount;
cache[mount] = app;
routes.push(mount);

View File

@ -320,7 +320,7 @@ class FoxxService {
var options = this.options.configuration;
_.each(definitions, function (dfn, name) {
var value = options[name] === undefined ? dfn.default : options[name];
config[name] = simple ? value : _.extend(_.clone(dfn), {
config[name] = simple ? value : _.extend({}, dfn, {
title: getReadableName(name),
current: value
});