Skip to content

Commit

Permalink
update fun-hooks to latest and update api (#3574)
Browse files Browse the repository at this point in the history
* use custom bind where non-standard mootools bind could cause issues

* replace missing 'rest' with implementation

* latest fun-hooks

* update package-lock.json

* update fun-hooks to latest and update api

* update fun-hooks to latest, fixes: #3576

* update package-lock.json
  • Loading branch information
snapwich authored and jaiminpanchal27 committed Feb 27, 2019
1 parent b6c5644 commit 36f1230
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 47 deletions.
6 changes: 3 additions & 3 deletions modules/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { STATUS } from '../src/constants';
import { ajax } from '../src/ajax';
import * as utils from '../src/utils';
import { config } from '../src/config';
import { hooks } from '../src/hook.js';
import { getHook } from '../src/hook.js';

const DEFAULT_CURRENCY_RATE_URL = 'https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=$$TODAY$$';
const CURRENCY_RATE_PRECISION = 4;
Expand Down Expand Up @@ -122,7 +122,7 @@ function initCurrency(url) {

utils.logInfo('Installing addBidResponse decorator for currency module', arguments);

hooks['addBidResponse'].before(addBidResponseHook, 100);
getHook('addBidResponse').before(addBidResponseHook, 100);

// call for the file if we haven't already
if (needToCallForCurrencyFile) {
Expand All @@ -148,7 +148,7 @@ function initCurrency(url) {
function resetCurrency() {
utils.logInfo('Uninstalling addBidResponse decorator for currency module', arguments);

hooks['addBidResponse'].getHooks({hook: addBidResponseHook}).remove();
getHook('addBidResponse').getHooks({hook: addBidResponseHook}).remove();

adServerCurrency = 'USD';
conversionCache = {};
Expand Down
2 changes: 1 addition & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function doAllSyncs(bidders) {

const thisSync = bidders.pop();
if (thisSync.no_cookie) {
doBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, doAllSyncs.bind(null, bidders));
doBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, utils.bind.call(doAllSyncs, null, bidders));
} else {
doAllSyncs(bidders);
}
Expand Down
70 changes: 35 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"babel-plugin-transform-object-assign": "^6.22.0",
"core-js": "^2.4.1",
"crypto-js": "^3.1.9-1",
"fun-hooks": "^0.6.5",
"fun-hooks": "^0.8.1",
"jsencrypt": "^3.0.0-rc.1",
"just-clone": "^1.0.2"
}
Expand Down
2 changes: 1 addition & 1 deletion src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels})

const adUnitCodes = _adUnitCodes;
const bids = _bidsReceived
.filter(adUnitsFilter.bind(this, adUnitCodes))
.filter(utils.bind.call(adUnitsFilter, this, adUnitCodes))
.reduce(groupByPlacement, {});
_callback.apply($$PREBID_GLOBAL$$, [bids, timedOut]);
} catch (e) {
Expand Down
6 changes: 1 addition & 5 deletions src/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ export let hook = funHooks({
ready: funHooks.SYNC | funHooks.ASYNC | funHooks.QUEUE
});

/**
* A map of global hook methods to allow easy extension of hooked functions that are intended to be extended globally
* @type {{}}
*/
export const hooks = hook.hooks;
export const getHook = hook.get;
2 changes: 1 addition & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ $$PREBID_GLOBAL$$.getAdserverTargeting = function (adUnitCode) {

function getBids(type) {
const responses = auctionManager[type]()
.filter(adUnitsFilter.bind(this, auctionManager.getAdUnitCodes()));
.filter(utils.bind.call(adUnitsFilter, this, auctionManager.getAdUnitCodes()));

// find the last auction id to get responses for most recent auction only
const currentAuctionId = auctionManager.getLastAuctionId();
Expand Down
11 changes: 11 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ export const internal = {
logInfo
};

var uniqueRef = {};
export let bind = function(a, b) { return b; }.bind(null, 1, uniqueRef)() === uniqueRef
? Function.prototype.bind
: function(bind) {
var self = this;
var args = Array.prototype.slice.call(arguments, 1);
return function() {
return self.apply(bind, args.concat(Array.prototype.slice.call(arguments)));
};
};

/*
* Substitutes into a string from a given map using the token
* Usage
Expand Down

0 comments on commit 36f1230

Please sign in to comment.