Skip to content

Commit

Permalink
replace broken utils.extend functionality with object.assign
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich committed Mar 17, 2017
1 parent cecb734 commit 7c6ecb3
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/adapters/adkernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const AdKernelAdapter = function AdKernelAdapter() {
* Create bid object for the bid manager
*/
function createBidObject(resp, bid, width, height) {
return utils.extend(bidfactory.createBid(1, bid), {
return Object.assign(bidfactory.createBid(1, bid), {
bidderCode: bid.bidder,
ad: formatAdMarkup(resp),
width: width,
Expand All @@ -189,7 +189,7 @@ const AdKernelAdapter = function AdKernelAdapter() {
* Create empty bid object for the bid manager
*/
function createEmptyBidObject(bid) {
return utils.extend(bidfactory.createBid(2, bid), {
return Object.assign(bidfactory.createBid(2, bid), {
bidderCode: bid.bidder
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/adapters/analytics/example2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { ajax } from 'src/ajax';
*/

import adapter from 'AnalyticsAdapter';
const utils = require('../../utils');

const url = 'https://httpbin.org/post';
const analyticsType = 'endpoint';

export default utils.extend(adapter(
export default Object.assign(adapter(
{
url,
analyticsType
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/analytics/roxot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const utils = require('../../utils');
const url = '//d.rxthdr.com/analytics';
const analyticsType = 'endpoint';

export default utils.extend(adapter(
export default Object.assign(adapter(
{
url,
analyticsType
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/analytics/sharethrough_analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const analyticsType = 'endpoint';
const STR_BIDDER_CODE = "sharethrough";
const STR_VERSION = "0.1.0";

export default utils.extend(adapter(
export default Object.assign(adapter(
{
emptyUrl,
analyticsType
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/appnexus.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ AppNexusAdapter = function AppNexusAdapter() {
}

//append custom attributes:
var paramsCopy = utils.extend({}, bid.params);
var paramsCopy = Object.assign({}, bid.params);

//delete attributes already used
delete paramsCopy.placementId;
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/xhb.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const XhbAdapter = function XhbAdapter() {
}

//append custom attributes:
let paramsCopy = utils.extend({}, bid.params);
let paramsCopy = Object.assign({}, bid.params);

//delete attributes already used
delete paramsCopy.placementId;
Expand Down
2 changes: 1 addition & 1 deletion src/bidmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function adjustBids(bid) {
if (code && $$PREBID_GLOBAL$$.bidderSettings && $$PREBID_GLOBAL$$.bidderSettings[code]) {
if (typeof $$PREBID_GLOBAL$$.bidderSettings[code].bidCpmAdjustment === objectType_function) {
try {
bidPriceAdjusted = $$PREBID_GLOBAL$$.bidderSettings[code].bidCpmAdjustment.call(null, bid.cpm, utils.extend({}, bid));
bidPriceAdjusted = $$PREBID_GLOBAL$$.bidderSettings[code].bidCpmAdjustment.call(null, bid.cpm, Object.assign({}, bid));
}
catch (e) {
utils.logError('Error during bid adjustment', 'bidmanager.js', e);
Expand Down
2 changes: 1 addition & 1 deletion src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ module.exports = (function () {
_public.getEvents = function () {
var arrayCopy = [];
utils._each(eventsFired, function (value) {
var newProp = utils.extend({}, value);
var newProp = Object.assign({}, value);
arrayCopy.push(newProp);
});

Expand Down
16 changes: 0 additions & 16 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,6 @@ exports.transformAdServerTargetingObj = function (targeting) {
}
};

//Copy all of the properties in the source objects over to the target object
//return the target object.
exports.extend = function (target, source) {
target = target || {};

this._each(source, function (value, prop) {
if (typeof source[prop] === objectType_object) {
target[prop] = this.extend(target[prop], source[prop]);
} else {
target[prop] = source[prop];
}
});

return target;
};

/**
* Parse a GPT-Style general size Array like `[[300, 250]]` or `"300x250,970x90"` into an array of sizes `["300x250"]` or '['300x250', '970x90']'
* @param {array[array|number]} sizeObj Input array or double array [300,250] or [[300,250], [728,90]]
Expand Down
7 changes: 5 additions & 2 deletions test/spec/adapters/lifestreet_spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {expect} from 'chai';
import adloader from 'src/adloader';
import bidmanager from 'src/bidmanager';
import * as utils from 'src/utils';
import LifestreetAdapter from 'src/adapters/lifestreet';

function copy(obj) {
return JSON.parse(JSON.stringify(obj));
}

const BIDDER_REQUEST = {
auctionStart: new Date().getTime(),
bidderCode: 'lifestreet',
Expand Down Expand Up @@ -44,7 +47,7 @@ describe ('LifestreetAdapter', () => {

beforeEach(() => {
tagRequests = [];
request = utils.extend(request, BIDDER_REQUEST);
request = copy(BIDDER_REQUEST);
sinon.stub(adloader, 'loadScript', (url, callback) => {
tagRequests.push(url);
callback();
Expand Down
6 changes: 3 additions & 3 deletions test/spec/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('Utils', function () {
c:'3'
};

var output = utils.extend(target, source);
var output = Object.assign(target, source);
assert.deepEqual(output, expectedResult);
});

Expand All @@ -140,7 +140,7 @@ describe('Utils', function () {
c:'3'
};

var output = utils.extend(target, source);
var output = Object.assign(target, source);
assert.deepEqual(output, source);
});

Expand All @@ -151,7 +151,7 @@ describe('Utils', function () {
};
var source = {};

var output = utils.extend(target, source);
var output = Object.assign(target, source);
assert.deepEqual(output, target);
});
});
Expand Down

0 comments on commit 7c6ecb3

Please sign in to comment.