Skip to content

Commit

Permalink
Add jsdoc types to common.js
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Oct 14, 2024
1 parent e6ba003 commit 6d36e60
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions options/options.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @typedef {import('../common')}
*/

'use strict';

( ( () =>
Expand Down
33 changes: 33 additions & 0 deletions scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var ExtensionApi = ( () =>
// eslint-disable-next-line no-var
var CurrentAppID;

/**
* @param {String} url
* @returns {Number}
*/
function GetAppIDFromUrl( url )
{
const appid = url.match( /\/(?:app|sub|bundle|friendsthatplay|gamecards|recommended|widget)\/(?<id>[0-9]+)/ );
Expand All @@ -44,6 +48,11 @@ function GetHomepage()
return 'https://steamdb.info/';
}

/**
* @param {String} message
* @param {String[]} substitutions
* @returns {String}
*/
function _t( message, substitutions = [] )
{
return ExtensionApi.i18n.getMessage( message, substitutions );
Expand All @@ -54,11 +63,23 @@ function GetLanguage()
return ExtensionApi.i18n.getUILanguage();
}

/**
* @callback GetOptionCallback
* @param {{[key: string]: any}} items
*/

/**
* @param {{[key: string]: any}} items
* @param {GetOptionCallback} callback
*/
function GetOption( items, callback )
{
ExtensionApi.storage.sync.get( items ).then( callback );
}

/**
* @param {String} option
*/
function SetOption( option, value )
{
const obj = {};
Expand All @@ -67,11 +88,23 @@ function SetOption( option, value )
ExtensionApi.storage.sync.set( obj );
}

/**
* @param {String} res
*/
function GetLocalResource( res )
{
return ExtensionApi.runtime.getURL( res );
}

/**
* @callback SendMessageToBackgroundScriptCallback
* @param {{success: Boolean, error?: String}?} data
*/

/**
* @param {String} message
* @param {SendMessageToBackgroundScriptCallback} callback
*/
function SendMessageToBackgroundScript( message, callback )
{
const errorCallback = ( error ) => callback( { success: false, error: error.message } );
Expand Down
4 changes: 4 additions & 0 deletions scripts/steamdb/global.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @typedef {import('../common')}
*/

'use strict';

const EXTENSION_INTEROP_VERSION = 2;
Expand Down
4 changes: 4 additions & 0 deletions scripts/store/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @typedef {import('../common')}
*/

/* global AddLinksInErrorBox */

'use strict';
Expand Down

0 comments on commit 6d36e60

Please sign in to comment.