Skip to content

Commit

Permalink
Remove deepExtend mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Jashepp committed Jul 12, 2017
1 parent 392a6a5 commit 515748a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 41 deletions.
2 changes: 1 addition & 1 deletion lib/core-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,5 @@ exports.preConfiguredProxy = (target, options)=>{
}
}
if (!proxyInterface || !client) throw Error("Target not found");
return client.proxyCom.createProxy(_.deepExtend(_.deepExtend({}, proxyInterface.options), {preConfigure: options}));
return client.proxyCom.createProxy(_.extend(_.extend({}, proxyInterface.options), {preConfigure: _.extend({},options)}));
};
2 changes: 1 addition & 1 deletion lib/proxy-communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const proxyCom = exports.proxyCom = class proxyCom {
}

createProxy(options = {}){
return this.proxyConstructor.createProxyInterface(_.extend(_.deepExtend({}, options), { basePromise: this.clientConnectionToHostPromise }));
return this.proxyConstructor.createProxyInterface(_.extend(_.extend({}, options), { basePromise: this.clientConnectionToHostPromise }));
}

};
4 changes: 2 additions & 2 deletions lib/proxy-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const proxyConstructor = exports.proxyConstructor = class proxyConstructor {
if (!newOperator2) newOperator2 = _.isConstructed(this, proxyTargetConstructorResult);
var proxyPromise = { constructorOptions, newOperator: newOperator2, property, args, argsActionID:0, proxyOptions: {}, timestamp: Date.now() };
if ('preConfigure' in proxyInterface.options && _.isObject(proxyInterface.options.preConfigure))
_.deepExtend(proxyPromise.proxyOptions, proxyInterface.options.preConfigure);
_.extend(proxyPromise.proxyOptions, proxyInterface.options.preConfigure);
proxyPromise.promise = new Promise((resolve2, reject2)=>{
var resolve = (...rArgs)=>{
self.endProxyPromise(proxyPromise, {resolve: true});
Expand All @@ -180,7 +180,7 @@ const proxyConstructor = exports.proxyConstructor = class proxyConstructor {
});
proxyInterface.promiseMap.set(proxyPromise.promise, proxyPromise);
proxyPromise.promise.configure = (...options)=>{
if (options.length > 0) _.deepExtend(proxyPromise.proxyOptions, ...options);
if (options.length > 0) _.extend(proxyPromise.proxyOptions, ...options);
return proxyPromise.promise;
};
return proxyPromise.promise;
Expand Down
21 changes: 1 addition & 20 deletions lib/underscore-with-mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,8 @@ const mixins = {
isEventEmitter(obj) {
let eventEmitter = mixins.isEventEmitter.eventEmitter = mixins.isEventEmitter.eventEmitter || require('events');
return (obj instanceof eventEmitter);
},

deepExtend(dest, ...source) {
for (var i = 0, l = source.length; i < l; i++) {
if (__.isArray(source[i]))
for (var j = 0, k = source[i].length; j < k; j++) {
var val = source[i][j];
if (__.isArray(val)) dest.push(mixins.deepExtend([], val));
else if (__.isObject(val)) dest.push(mixins.deepExtend({}, val));
else dest.push(val);
}
else if (__.isObject(source[i]))
for (var key in source[i]) {
var val = source[i][key];
if (__.isArray(val)) dest[key] = mixins.deepExtend([], val);
else if (__.isObject(val)) dest[key] = mixins.deepExtend({}, val);
else dest[key] = val;
}
}
return dest;
}

};

// Do not use underscore's _.mixin;
Expand Down
17 changes: 0 additions & 17 deletions tests/underscore-with-mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,6 @@ describe("Lib: underscore-with-mixins",()=>{
expect('test').to.not.satisfy(_.isStream.bind(_));
});

it("mixin #deepExtend",()=>{
expect(_).to.have.ownProperty('deepExtend');
expect(_.deepExtend).to.be.a('function');
var obj1 = { a:1, b:2, c:3, d:{ e:4 } };
var obj2 = { foo:'bar', answer:42, sub:{ hello:'world' } };
var testobj1 = _.extend({},obj1,obj2);
var testobj1str = JSON.stringify(testobj1);
var testobj2 = _.deepExtend({},obj1,obj2);
var testobj2str = JSON.stringify(testobj2);
expect(testobj1str).to.equal(testobj2str);
obj1.d.f = 5;
obj2.sub.hello = 'friend';
//expect(JSON.stringify(testobj1)).to.not.equal(testobj1str);
expect(JSON.stringify(testobj2)).to.not.equal(JSON.stringify(testobj1));
expect(JSON.stringify(testobj2)).to.equal(testobj2str);
});

it("should have disabled methods",()=>{
expect(_.isFunction(_)).to.be.false;
expect(_.mixin).to.throw(Error);
Expand Down

0 comments on commit 515748a

Please sign in to comment.