Skip to content

Commit 36f1230

Browse files
snapwichjaiminpanchal27
authored andcommitted
update fun-hooks to latest and update api (#3574)
* 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
1 parent b6c5644 commit 36f1230

File tree

8 files changed

+54
-47
lines changed

8 files changed

+54
-47
lines changed

modules/currency.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { STATUS } from '../src/constants';
33
import { ajax } from '../src/ajax';
44
import * as utils from '../src/utils';
55
import { config } from '../src/config';
6-
import { hooks } from '../src/hook.js';
6+
import { getHook } from '../src/hook.js';
77

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

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

125-
hooks['addBidResponse'].before(addBidResponseHook, 100);
125+
getHook('addBidResponse').before(addBidResponseHook, 100);
126126

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

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

153153
adServerCurrency = 'USD';
154154
conversionCache = {};

modules/prebidServerBidAdapter/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function doAllSyncs(bidders) {
169169

170170
const thisSync = bidders.pop();
171171
if (thisSync.no_cookie) {
172-
doBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, doAllSyncs.bind(null, bidders));
172+
doBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, utils.bind.call(doAllSyncs, null, bidders));
173173
} else {
174174
doAllSyncs(bidders);
175175
}

package-lock.json

+35-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"babel-plugin-transform-object-assign": "^6.22.0",
9393
"core-js": "^2.4.1",
9494
"crypto-js": "^3.1.9-1",
95-
"fun-hooks": "^0.6.5",
95+
"fun-hooks": "^0.8.1",
9696
"jsencrypt": "^3.0.0-rc.1",
9797
"just-clone": "^1.0.2"
9898
}

src/auction.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels})
157157

158158
const adUnitCodes = _adUnitCodes;
159159
const bids = _bidsReceived
160-
.filter(adUnitsFilter.bind(this, adUnitCodes))
160+
.filter(utils.bind.call(adUnitsFilter, this, adUnitCodes))
161161
.reduce(groupByPlacement, {});
162162
_callback.apply($$PREBID_GLOBAL$$, [bids, timedOut]);
163163
} catch (e) {

src/hook.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@ export let hook = funHooks({
55
ready: funHooks.SYNC | funHooks.ASYNC | funHooks.QUEUE
66
});
77

8-
/**
9-
* A map of global hook methods to allow easy extension of hooked functions that are intended to be extended globally
10-
* @type {{}}
11-
*/
12-
export const hooks = hook.hooks;
8+
export const getHook = hook.get;

src/prebid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ $$PREBID_GLOBAL$$.getAdserverTargeting = function (adUnitCode) {
172172

173173
function getBids(type) {
174174
const responses = auctionManager[type]()
175-
.filter(adUnitsFilter.bind(this, auctionManager.getAdUnitCodes()));
175+
.filter(utils.bind.call(adUnitsFilter, this, auctionManager.getAdUnitCodes()));
176176

177177
// find the last auction id to get responses for most recent auction only
178178
const currentAuctionId = auctionManager.getLastAuctionId();

src/utils.js

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ export const internal = {
4040
logInfo
4141
};
4242

43+
var uniqueRef = {};
44+
export let bind = function(a, b) { return b; }.bind(null, 1, uniqueRef)() === uniqueRef
45+
? Function.prototype.bind
46+
: function(bind) {
47+
var self = this;
48+
var args = Array.prototype.slice.call(arguments, 1);
49+
return function() {
50+
return self.apply(bind, args.concat(Array.prototype.slice.call(arguments)));
51+
};
52+
};
53+
4354
/*
4455
* Substitutes into a string from a given map using the token
4556
* Usage

0 commit comments

Comments
 (0)