Skip to content

Commit 47e6561

Browse files
authored
Core Utils: fix jsdoc warnings (prebid#11694)
* Update utils.js * Update perfMetrics.js * Update ttlCollection.js * Update adpod.js * Update consentManagementGpp.js * Update consentManagementGpp.js * Update consentManagement.js * Update consentManagementUsp.js * Update currency.js * Update dfpAdServerVideo.js * Update instreamTracking.js * Update s2sTesting.js * Update sizeMapping.js * Update topicsFpdModule.js * Update uid2IdSystem.js * Update consentManagementUsp.js * Update sizeMapping.js
1 parent 5b7df85 commit 47e6561

14 files changed

+79
-65
lines changed

modules/adpod.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ export function callPrebidCacheAfterAuction(bids, callback) {
451451
/**
452452
* Compare function to be used in sorting long-form bids. This will compare bids on price per second.
453453
* @param {Object} bid
454-
* @param {Object} bid
455454
*/
456455
export function sortByPricePerSecond(a, b) {
457456
if (a.adserverTargeting[TARGETING_KEYS.PRICE_BUCKET] / a.video.durationBucket < b.adserverTargeting[TARGETING_KEYS.PRICE_BUCKET] / b.video.durationBucket) {
@@ -465,10 +464,10 @@ export function sortByPricePerSecond(a, b) {
465464

466465
/**
467466
* This function returns targeting keyvalue pairs for long-form adserver modules. Freewheel and GAM are currently supporting Prebid long-form
468-
* @param {Object} options
469-
* @param {Array[string]} codes
470-
* @param {function} callback
471-
* @returns targeting kvs for adUnitCodes
467+
* @param {Object} options - Options for targeting.
468+
* @param {Array<string>} options.codes - Array of ad unit codes.
469+
* @param {function} options.callback - Callback function to handle the targeting key-value pairs.
470+
* @returns {Object} Targeting key-value pairs for ad unit codes.
472471
*/
473472
export function getTargeting({ codes, callback } = {}) {
474473
if (!callback) {

modules/consentManagement.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ const cmpCallMap = {
3535

3636
/**
3737
* This function reads the consent string from the config to obtain the consent information of the user.
38-
* @param {function({})} onSuccess acts as a success callback when the value is read from config; pass along consentObject from CMP
38+
* @param {Object} options - An object containing the callbacks.
39+
* @param {function(Object): void} options.onSuccess - Acts as a success callback when the value is read from config; pass along consentObject from CMP.
40+
* @param {function(string, ...Object?): void} [options.onError] - Acts as an error callback while interacting with CMP; pass along an error message (string) and any extra error arguments (purely for logging). Optional.
3941
*/
4042
function lookupStaticConsentData({onSuccess, onError}) {
4143
processCmpData(staticConsentData, {onSuccess, onError})
@@ -45,8 +47,10 @@ function lookupStaticConsentData({onSuccess, onError}) {
4547
* This function handles interacting with an IAB compliant CMP to obtain the consent information of the user.
4648
* Given the async nature of the CMP's API, we pass in acting success/error callback functions to exit this function
4749
* based on the appropriate result.
48-
* @param {function({})} onSuccess acts as a success callback when CMP returns a value; pass along consentObjectfrom CMP
49-
* @param {function(string, ...{}?)} cmpError acts as an error callback while interacting with CMP; pass along an error message (string) and any extra error arguments (purely for logging)
50+
* @param {Object} options - An object containing the callbacks.
51+
* @param {function(Object): void} options.onSuccess - Acts as a success callback when CMP returns a value; pass along consentObject from CMP.
52+
* @param {function(string, ...Object?): void} options.onError - Acts as an error callback while interacting with CMP; pass along an error message (string) and any extra error arguments (purely for logging).
53+
* @param {function(Object): void} options.onEvent - Acts as an event callback for processing TCF data events from CMP.
5054
*/
5155
function lookupIabConsent({onSuccess, onError, onEvent}) {
5256
function cmpResponseCallback(tcfData, success) {

modules/consentManagementGpp.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ class GPP11Client extends GPPClient {
304304
* This function handles interacting with an IAB compliant CMP to obtain the consent information of the user.
305305
* Given the async nature of the CMP's API, we pass in acting success/error callback functions to exit this function
306306
* based on the appropriate result.
307-
* @param {function({})} onSuccess acts as a success callback when CMP returns a value; pass along consentObjectfrom CMP
308-
* @param {function(string, ...{}?)} cmpError acts as an error callback while interacting with CMP; pass along an error message (string) and any extra error arguments (purely for logging)
307+
* @param {Object} options - An object containing the callbacks.
308+
* @param {function(Object): void} options.onSuccess - Acts as a success callback when CMP returns a value; pass along consentObject from CMP.
309+
* @param {function(string, ...Object?): void} options.onError - Acts as an error callback while interacting with CMP; pass along an error message (string) and any extra error arguments (purely for logging).
310+
* @param {function(): Object} [mkCmp=cmpClient] - A function to create the CMP client. Defaults to `cmpClient`.
309311
*/
310312
export function lookupIabConsent({onSuccess, onError}, mkCmp = cmpClient) {
311313
pipeCallbacks(() => GPPClient.init(mkCmp).then(([client, gppDataPm]) => gppDataPm), {onSuccess, onError});
@@ -434,7 +436,6 @@ function processCmpData(consentData) {
434436
/**
435437
* Stores CMP data locally in module to make information available in adaptermanager.js for later in the auction
436438
* @param {{}} gppData the result of calling a CMP's `getGPPData` (or equivalent)
437-
* @param {{}} sectionData map from GPP section name to the result of calling a CMP's `getSection` (or equivalent)
438439
*/
439440
export function storeConsentData(gppData = {}) {
440441
consentData = {

modules/consentManagementUsp.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,12 @@ export const requestBidsHook = timedAuctionHook('usp', function requestBidsHook(
163163
/**
164164
* This function checks the consent data provided by USPAPI to ensure it's in an expected state.
165165
* If it's bad, we exit the module depending on config settings.
166-
* If it's good, then we store the value and exits the module.
167-
* @param {object} consentObject required; object returned by USPAPI that contains user's consent choices
168-
* @param {function(string)} onSuccess callback accepting the resolved consent USP consent string
169-
* @param {function(string, ...{}?)} onError callback accepting error message and any extra error arguments (used purely for logging)
166+
* If it's good, then we store the value and exit the module.
167+
*
168+
* @param {Object} consentObject - The object returned by USPAPI that contains the user's consent choices.
169+
* @param {Object} callbacks - An object containing the callback functions.
170+
* @param {function(string): void} callbacks.onSuccess - Callback accepting the resolved USP consent string.
171+
* @param {function(string, ...Object?): void} callbacks.onError - Callback accepting an error message and any extra error arguments (used purely for logging).
170172
*/
171173
function processUspData(consentObject, {onSuccess, onError}) {
172174
const valid = !!(consentObject && consentObject.usPrivacy);

modules/currency.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export let responseReady = defer();
2828

2929
/**
3030
* Configuration function for currency
31+
* @param {object} config
3132
* @param {string} [config.adServerCurrency = 'USD']
3233
* ISO 4217 3-letter currency code that represents the target currency. (e.g. 'EUR'). If this value is present,
3334
* the currency conversion feature is activated.

modules/dfpAdServerVideo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) {
308308
* Builds a video url from a base dfp video url and a winning bid, appending
309309
* Prebid-specific key-values.
310310
* @param {Object} components base video adserver url parsed into components object
311-
* @param {AdapterBidResponse} bid winning bid object to append parameters from
311+
* @param {Object} bid winning bid object to append parameters from
312312
* @param {Object} options Options which should be used to construct the URL (used for custom params).
313313
* @return {string} video url
314314
*/
@@ -325,7 +325,7 @@ function buildUrlFromAdserverUrlComponents(components, bid, options) {
325325
/**
326326
* Returns the encoded vast url if it exists on a bid object, only if prebid-cache
327327
* is disabled, and description_url is not already set on a given input
328-
* @param {AdapterBidResponse} bid object to check for vast url
328+
* @param {Object} bid object to check for vast url
329329
* @param {Object} components the object to check that description_url is NOT set on
330330
* @param {string} prop the property of components that would contain description_url
331331
* @return {string | undefined} The encoded vast url if it exists, or undefined
@@ -336,7 +336,7 @@ function getDescriptionUrl(bid, components, prop) {
336336

337337
/**
338338
* Returns the encoded `cust_params` from the bid.adserverTargeting and adds the `hb_uuid`, and `hb_cache_id`. Optionally the options.params.cust_params
339-
* @param {AdapterBidResponse} bid
339+
* @param {Object} bid
340340
* @param {Object} options this is the options passed in from the `buildDfpVideoUrl` function
341341
* @return {Object} Encoded key value pairs for cust_params
342342
*/

modules/instreamTracking.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ const whitelistedResources = /video|fetch|xmlhttprequest|other/;
4141
*
4242
* Note: this is a workaround till a better approach is engineered.
4343
*
44-
* @param {Array<AdUnit>} adUnits
45-
* @param {Array<Bid>} bidsReceived
46-
* @param {Array<BidRequest>} bidderRequests
44+
* @param {object} config
45+
* @param {Array<AdUnit>} config.adUnits
46+
* @param {Array<Bid>} config.bidsReceived
47+
* @param {Array<BidRequest>} config.bidderRequests
4748
*
4849
* @return {boolean} returns TRUE if tracking started
4950
*/

modules/s2sTesting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ s2sTesting.getSourceBidderMap = function(adUnits = [], allS2SBidders = []) {
4444

4545
/**
4646
* @function calculateBidSources determines the source for each s2s bidder based on bidderControl weightings. these can be overridden at the adUnit level
47-
* @param s2sConfigs server-to-server configuration
47+
* @param s2sConfig server-to-server configuration
4848
*/
4949
s2sTesting.calculateBidSources = function(s2sConfig = {}) {
5050
// calculate bid source (server/client) for each s2s bidder

modules/sizeMapping.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ config.getConfig('sizeConfig', config => setSizeConfig(config.sizeConfig));
3535
* Returns object describing the status of labels on the adUnit or bidder along with labels passed into requestBids
3636
* @param bidOrAdUnit the bidder or adUnit to get label info on
3737
* @param activeLabels the labels passed to requestBids
38-
* @returns {LabelDescriptor}
38+
* @returns {object}
3939
*/
4040
export function getLabels(bidOrAdUnit, activeLabels) {
4141
if (bidOrAdUnit.labelAll) {
@@ -66,14 +66,18 @@ if (FEATURES.VIDEO) {
6666
}
6767

6868
/**
69-
* Resolves the unique set of the union of all sizes and labels that are active from a SizeConfig.mediaQuery match
70-
* @param {Array<string>} labels Labels specified on adUnit or bidder
71-
* @param {boolean} labelAll if true, all labels must match to be enabled
72-
* @param {Array<string>} activeLabels Labels passed in through requestBids
73-
* @param {object} mediaTypes A mediaTypes object describing the various media types (banner, video, native)
74-
* @param {Array<Array<number>>} sizes Sizes specified on adUnit (deprecated)
75-
* @param {Array<SizeConfig>} configs
76-
* @returns {{labels: Array<string>, sizes: Array<Array<number>>}}
69+
* Resolves the unique set of the union of all sizes and labels that are active from a SizeConfig.mediaQuery match.
70+
*
71+
* @param {Object} options - The options object.
72+
* @param {Array<string>} [options.labels=[]] - Labels specified on adUnit or bidder.
73+
* @param {boolean} [options.labelAll=false] - If true, all labels must match to be enabled.
74+
* @param {Array<string>} [options.activeLabels=[]] - Labels passed in through requestBids.
75+
* @param {Object} mediaTypes - A mediaTypes object describing the various media types (banner, video, native).
76+
* @param {Array<SizeConfig>} configs - An array of SizeConfig objects.
77+
* @returns {Object} - An object containing the active status, media types, and filter results.
78+
* @returns {boolean} return.active - Whether the media types are active.
79+
* @returns {Object} return.mediaTypes - The media types object.
80+
* @returns {Object} [return.filterResults] - The filter results before and after applying size filtering.
7781
*/
7882
export function resolveStatus({labels = [], labelAll = false, activeLabels = []} = {}, mediaTypes, configs = sizeConfig) {
7983
let maps = evaluateSizeConfig(configs);

modules/topicsFpdModule.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ export function receiveMessage(evt) {
201201

202202
/**
203203
Function to store Topics data received from iframe in storage(name: "prebid:topics")
204-
* @param {Topics} topics
204+
* @param {string} bidder
205+
* @param {object} topics
205206
*/
206207
export function storeInLocalStorage(bidder, topics) {
207208
const storedSegments = new Map(safeJSONParse(coreStorage.getDataFromLocalStorage(topicStorageName)));

modules/uid2IdSystem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const uid2IdSubmodule = {
6969
/**
7070
* performs action to obtain id and return a value.
7171
* @function
72-
* @param {SubmoduleConfig} [configparams]
72+
* @param {SubmoduleConfig} config
7373
* @param {ConsentData|undefined} consentData
7474
* @returns {uid2Id}
7575
*/

src/utils.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ export function isEmptyStr(str) {
382382
* Iterate object with the function
383383
* falls back to es5 `forEach`
384384
* @param {Array|Object} object
385-
* @param {Function(value, key, object)} fn
385+
* @param {Function} fn - The function to execute for each element. It receives three arguments: value, key, and the original object.
386+
* @returns {void}
386387
*/
387388
export function _each(object, fn) {
388389
if (isFn(object?.forEach)) return object.forEach(fn, this);
@@ -397,7 +398,7 @@ export function contains(a, obj) {
397398
* Map an array or object into another array
398399
* given a function
399400
* @param {Array|Object} object
400-
* @param {Function(value, key, object)} callback
401+
* @param {Function} callback - The function to execute for each element. It receives three arguments: value, key, and the original object.
401402
* @return {Array}
402403
*/
403404
export function _map(object, callback) {
@@ -500,7 +501,6 @@ export function insertHtmlIntoIframe(htmlCode) {
500501
/**
501502
* Inserts empty iframe with the specified `url` for cookie sync
502503
* @param {string} url URL to be requested
503-
* @param {string} encodeUri boolean if URL should be encoded before inserted. Defaults to true
504504
* @param {function} [done] an optional exit callback, used when this usersync pixel is added during an async process
505505
* @param {Number} [timeout] an optional timeout in milliseconds for the iframe to load before calling `done`
506506
*/
@@ -737,7 +737,6 @@ export function delayExecution(func, numRequiredCalls) {
737737

738738
/**
739739
* https://stackoverflow.com/a/34890276/428704
740-
* @export
741740
* @param {Array} xs
742741
* @param {string} key
743742
* @returns {Object} {${key_value}: ${groupByArray}, key_value: {groupByArray}}
@@ -953,9 +952,9 @@ export function buildUrl(obj) {
953952
* This function deeply compares two objects checking for their equivalence.
954953
* @param {Object} obj1
955954
* @param {Object} obj2
956-
* @param checkTypes {boolean} if set, two objects with identical properties but different constructors will *not*
957-
* be considered equivalent.
958-
* @returns {boolean}
955+
* @param {Object} [options] - Options for comparison.
956+
* @param {boolean} [options.checkTypes=false] - If set, two objects with identical properties but different constructors will *not* be considered equivalent.
957+
* @returns {boolean} - Returns `true` if the objects are equivalent, `false` otherwise.
959958
*/
960959
export function deepEqual(obj1, obj2, {checkTypes = false} = {}) {
961960
if (obj1 === obj2) return true;
@@ -1090,7 +1089,7 @@ export function memoize(fn, key = function (arg) { return arg; }) {
10901089

10911090
/**
10921091
* Sets dataset attributes on a script
1093-
* @param {Script} script
1092+
* @param {HTMLScriptElement} script
10941093
* @param {object} attributes
10951094
*/
10961095
export function setScriptAttributes(script, attributes) {

src/utils/perfMetrics.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export function metricsFactory({now = getTime, mkNode = makeNode, mkTimer = make
6363
/**
6464
* Get the tame passed since `checkpoint`, and optionally save it as a metric.
6565
*
66-
* @param checkpoint checkpoint name
67-
* @param metric? metric name
68-
* @return {number} time between now and `checkpoint`
66+
* @param {string} checkpoint checkpoint name
67+
* @param {string} [metric] - The name of the metric to save. Optional.
68+
* @returns {number|null} - The time in milliseconds between now and the checkpoint, or `null` if the checkpoint is not found.
6969
*/
7070
function timeSince(checkpoint, metric) {
7171
const ts = getTimestamp(checkpoint);
@@ -79,10 +79,10 @@ export function metricsFactory({now = getTime, mkNode = makeNode, mkTimer = make
7979
/**
8080
* Get the time passed between `startCheckpoint` and `endCheckpoint`, optionally saving it as a metric.
8181
*
82-
* @param startCheckpoint begin checkpoint
83-
* @param endCheckpoint end checkpoint
84-
* @param metric? metric name
85-
* @return {number} time passed between `startCheckpoint` and `endCheckpoint`
82+
* @param {string} startCheckpoint - The name of the starting checkpoint.
83+
* @param {string} endCheckpoint - The name of the ending checkpoint.
84+
* @param {string} [metric] - The name of the metric to save. Optional.
85+
* @returns {number|null} - The time in milliseconds between `startCheckpoint` and `endCheckpoint`, or `null` if either checkpoint is not found.
8686
*/
8787
function timeBetween(startCheckpoint, endCheckpoint, metric) {
8888
const start = getTimestamp(startCheckpoint);
@@ -128,25 +128,25 @@ export function metricsFactory({now = getTime, mkNode = makeNode, mkTimer = make
128128
}
129129

130130
/**
131-
* @typedef {function: T} HookFn
132-
* @property {function(T): void} bail
131+
* @typedef {Function} HookFn
132+
* @property {Function(T): void} bail
133133
*
134134
* @template T
135-
* @typedef {T: HookFn} TimedHookFn
136-
* @property {function(): void} stopTiming
135+
* @typedef {HookFn} TimedHookFn
136+
* @property {Function(): void} stopTiming
137137
* @property {T} untimed
138138
*/
139139

140140
/**
141141
* Convenience method for measuring time spent in a `.before` or `.after` hook.
142142
*
143143
* @template T
144-
* @param name metric name
145-
* @param {HookFn} next the hook's `next` (first) argument
146-
* @param {function(TimedHookFn): T} fn a function that will be run immediately; it takes `next`,
144+
* @param {string} name - The metric name.
145+
* @param {HookFn} next - The hook's `next` (first) argument.
146+
* @param {function(TimedHookFn): T} fn - A function that will be run immediately; it takes `next`,
147147
* where both `next` and `next.bail` automatically
148148
* call `stopTiming` before continuing with the original hook.
149-
* @return {T} fn's return value
149+
* @return {T} - The return value of `fn`.
150150
*/
151151
function measureHookTime(name, next, fn) {
152152
const stopTiming = startTiming(name);
@@ -208,10 +208,11 @@ export function metricsFactory({now = getTime, mkNode = makeNode, mkTimer = make
208208
* ```
209209
*
210210
*
211-
* @param propagate if false, the forked metrics will not be propagated here
212-
* @param stopPropagation if true, propagation from the new metrics is stopped here - instead of
213-
* continuing up the chain (if for example these metrics were themselves created through `.fork()`)
214-
* @param includeGroups if true, the forked metrics will also replicate metrics that were propagated
211+
* @param {Object} [options={}] - Options for forking the metrics.
212+
* @param {boolean} [options.propagate=true] - If false, the forked metrics will not be propagated here.
213+
* @param {boolean} [options.stopPropagation=false] - If true, propagation from the new metrics is stopped here, instead of
214+
* continuing up the chain (if for example these metrics were themselves created through `.fork()`).
215+
* @param {boolean} [options.includeGroups=false] - If true, the forked metrics will also replicate metrics that were propagated
215216
* here from elsewhere. For example:
216217
* ```
217218
* const metrics = newMetrics();
@@ -222,6 +223,7 @@ export function metricsFactory({now = getTime, mkNode = makeNode, mkTimer = make
222223
* withoutGroups.getMetrics() // {}
223224
* withGroups.getMetrics() // {foo: ['bar']}
224225
* ```
226+
* @returns {Object} - The new metrics object.
225227
*/
226228
function fork({propagate = true, stopPropagation = false, includeGroups = false} = {}) {
227229
return makeMetrics(mkNode([[self, {propagate, stopPropagation, includeGroups}]]), rename);

0 commit comments

Comments
 (0)